What is the difference between local storage vs cookies?

On client and server, the following storages are available: local storage, session storage, and cookies.

The Local Storage is designed for storage that spans multiple windows and lasts beyond the current session. In particular, Web applications may wish to store megabytes of user data, such as entire user-authored documents or a user’s mailbox, on the client side for performance reasons. Cookies do not handle this case well because they are transmitted with every request.

Local Storage is available for every page and remains even when the web browser is closed, but you cannot read it on the server.

The stored data has no expiration date in local storage. With cookies, you can set the expiration duration.

If you want to clear local storage, then do it by clearing the browser cache. You can also use JavaScript for this. Local Storage is for client side, whereas cookies are for the client as well as server side.


sessionStorage is great for easily and quickly saving session-related data for the lifetime of a web page session.

However, when a browser tab is closed, but then re-opened by anybody with access to the “Recent Tabs” section of a browser, they can once again access the session data.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.