When is localStorage cleared?

How long can I expect data to be stored in localStorage. How long will the local user data of the local user last? If the user does not clear it, will it continue until the browser is reinstalled?

How consistent is this between browsers?

+84
html5 local-storage
Dec 16 '11 at 16:27
source share
4 answers

W3C project says it

User agents should expire from local storage areas only for security reasons or at the request of the user. User agents should always avoid deleting data, but a script that can access that data.

So, if browsers follow the specification, it should remain until the user deletes it in all browsers, I did not find any deleted in any of my projects.

A good article to read is also http://ejohn.org/blog/dom-storage/

+76
Dec 16 '11 at 16:33
source share

localStorage is also known as web storage, HTML5 storage, and DOM storage (all of which mean the same thing).

localStorage is similar to sessionStorage, except that the data stored in localStorage does not expire, and the data stored in sessionStorage is cleared when the browsing session ends (i.e. when the browser is closed).

localStorage is available in all browsers, but persistence is not performed sequentially. In particular, localStorage can be cleared by user action and can be deleted unintentionally (who would think that clearing all cookies also clears localStorage?).

In Firefox, localStorage is cleared when these three conditions are met: (a) the user clears the recent history, (b) the selected cookies are cleared, (c) the time range is "All"

In Chrome, localStorage is cleared when these conditions are met: (a) clear browsing data, (b) “cookies and other site data” selected, (c) timeframe “from the beginning of time”. In Chrome, you can now remove localStorage for one specific site .

In IE, clear localStorage: (a) Tools - Internet Options, (b) General tab, (c) delete browsing history upon exit, (d) provide “cookies and website data” (or “temporary Internet files” and files website "), (e) consider unchecking the" Save Favorites website data at the top

In Safari: (a) Click Safari (b) Settings (c) Select the Privacy tab (d) Click Delete All Website Data (e) Click "Delete Now"

Opera Despite the excellent localStorage articles from the Opera website, I have not yet found clear (non-programmatic) instructions for users on how to clean up localStorage. If anyone finds, leave a comment below this answer with a link.




The Opera developer site has an excellent summary of localStorage:

The current way of storing data on the client side - cookies - this is the Problem:

  • Low size: cookies usually have a maximum size of about 4 KB, which is not very good for storing any complex data.

  • It is difficult for cookies to track two or more transactions on the same site, which can occur in two or more different tabs.

  • Cookies

    can be used using methods such as cross-site scripting, which leads to security breaches

Other (less popular) alternatives to cookies include methods that include query strings, hidden form fields, local shared objects based on flash memory, etc. Each with its own set of issues related to security, ease of use, size restrictions, etc. Thus, so far we have used rather poor ways of storing data to end users. We need the best way that web storage comes in.

Web storage

The W3C Web Storage specification was developed as the best way to store data on the client side. It has two different types of storage: session storage and local storage.

Both the session and the local storage, as a rule, can store 5 MB of data per domain, which is much more than cookies.

Resources

https://dev.opera.com/articles/web-storage/

http://www.quirksmode.org/html5/storage.html

http://www.ghacks.net/2015/02/05/how-to-clear-web-storage-in-your-browser-of-choice/

https://nakedsecurity.sophos.com/2014/11/05/how-to-clear-out-cookies-flash-cookies-and-local-storage/

http://www.opera.com/dragonfly/documentation/storage/

DOMStorage MDN article (written by John Resig)

http://ejohn.org/blog/dom-storage/

+81
May 08 '16 at
source share

The content in localstorage is persistent as long as the user decides to clear the storage (all or one value inside it)

On browser consistency, localstorage is currently available on every major browser, including IE8 + (see http://caniuse.com/#feat=namevalue-storage )

+2
Dec 16 '11 at 16:41
source share

In Chrome, when executing "clear browser data", if you select "Cookies and other site and plugin data", then sessionStorage data will be deleted.

+1
Apr 17 '16 at 19:03
source share



All Articles