Coder Perfect

When does localStorage become deleted?


How long do you think data will be retained in localStorage? How long will the data in a typical user’s localStorage last? Will it stay till the user reinstalls the browser if the user doesn’t clear it?

Is this true for all browsers?

Asked by Bnicholas

Solution #1

Web Storage, HTML5 Storage, and DOM Storage are all terms for localStorage (these all mean the same thing).

Data stored in localStorage does not expire, however data stored in sessionStorage is erased when the browsing session ends (i.e. when the browser / browser tab is closed). Session storage is utilized far less frequently than localStorage, and it only exists within the current browser tab; two tabs launched with the same website will have distinct sessionStorage data. The data in sessionStorage survives page refresh but not tab closing/opening. Data from the same origin, on the other hand, is shared across all tabs and windows. LocalStorage data does not expire; it persists even after the browser has been restarted and the operating system has been rebooted. Source

All browsers support localStorage, however persistence isn’t always implemented consistently. In particular, localStorage can be cleared by user action and may be cleared inadvertently (who would think that clearing all cookies also clears localStorage?).

When these three conditions are met in Firefox, localStorage is cleared: (a) The user clears recent history, (b) the user chooses to clear cookies, and (c) the time range is “Everything.”

When certain requirements are met in Chrome, localStorage is cleared: (a) clean browsing data, (b) “cookies and other site data” is selected, and (c) timeframe is “from beginning of time.” It’s now possible to erase localStorage for a single site in Chrome.

To clear localStorage in Internet Explorer, type: (a) Internet Options, (b) Internet Options, (c) Internet Options, (d) Internet Options, ( (b) Select the General tab, (c) remove browsing history on exit, (d) select “Cookies and website data” (or “temporary internet files and website files”), (e) uncheck “Preserve Favorites website data” at the top.

In Safari, go to (a) Safari, (b) Preferences, (c) Privacy, (d) Remove all website data, and (e) Remove Now.

Despite the fact that the Opera site has good articles on localStorage, I have yet to find clear (non-programmatic) instructions for users on how to remove localStorage. Please post a comment below this answer with a reference link if you locate it.

The Opera developer site gives a great overview of localStorage:


How to clear Web Storage in your browser of choice

MDN article about DOMStorage (written by John Resig)

Answered by cssyphus

Solution #2

This is according to a W3C draft.

So, if browsers follow the specification, it should last until the user removes it from all browsers; I haven’t seen any that have removed it from any of my projects. is another a nice post to read.

Answered by Dominic Green

Solution #3

Unlimited. The data is saved even if the browser or operating system is restarted.

In LocalStorage, each domain can store a minimum of 5MB of data.

Some browsers allow you to save up to 1GB of data.

Answered by Hasan Sefa Ozalp

Solution #4

As long as the user does not select to clear the storage, the content in localstorage remains (entirely or a single value inside it)

Localstorage is currently supported on every major browser, including IE8+ (see for browser consistency.

Answered by Fabrizio Calderan

Solution #5

If you choose ‘Cookies and other site and plugin data’ in Chrome’s ‘clear browsing data’ option, sessionStorage data will be deleted.

Answered by Uday Sravan K

Post is based on