Local Storage vs Session Storage vs Cookie Storage

Local Storage

  • Stores data with no expiry date
  • Cleared only via JavaScript or clearing browser cache
  • The storage limit is the largest of the 3 as big as 5MB
  • Not supported by older browsers IE7 or lower
  • Works on same-origin policy. So, data stored will only be available on the same origin.

Session Storage

  • Stores data only for the duration of the session, when the user closes their browser the data is lost
  • Top-level browsing context, therefore it’s unique to each browser tab
  • Storage limit is larger than cookies at 5MB
  • Not supported by older browsers IE7 or lower


  • Stores data that can be transferred to the server via headers
  • LocalStorage and SessionStorage can only be accessed on client-side
  • Expiry is set on creation of the cookie
  • Storage limit is smallest at 4kb
  • Cookies can be made secure making client side unable to read the contents. This is important for authentication to store user tokens.




Software Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Angular Version 8.0 on its way.

Working with Pre-request & Test in Postman

Destructuring Assignment JavaScript

Katalon Automation setup and How to create a simple Test suite.

Functions to the Rescue

A guide to KoaJs.

Run javaScript code when UI thread gets updated — Worklets

Functional Programming tricks for simplifying and improving code

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Software Developer

More from Medium

Conditional Statement in JS — with examples

How to draw Breadcrumbs in the Google Map using Vuejs

How to use the Throttle function in javascript to speed up your code.

Bootstrap a frontend project with Primereact and Typescript