Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does HTML5 localStorage persist across browser instances?

I had a similar question to this one but the answers seem a bit cryptic and I'm still not quite "getting" localStorage.

  1. If I save data to localStorage, and the user closes the browser, does that data get wiped out? Or is it still accessible when they open up a new browser instance?
  2. Is localStorage data available to all instances of a browser, or does each browser instance (say, for whatever reason, the user has 5 Firefox instances opened) get its own localStorage?
  3. When a user flushes all cookies & session data, does localStorage also get wiped out?
like image 594
IAmYourFaja Avatar asked Dec 17 '13 19:12

IAmYourFaja


People also ask

Does local storage persist across different browsers?

Local Storage is "local" in that exact browser and ONLY in that browser. To retrieve something stored in Local Storage, you must use the same browser, the same key and retrieve it from a page in the same origin (e.g. domain).

Where is HTML5 local storage located?

From the JavaScript code, HTML5 local storage may be accessed through a localStorage object on the global window object. The localStorage object stores the data without any expiration date. The data is not wiped, even after closing the browser, and may be accessed at any time.

What is persistent local storage in HTML5?

Using HTML5 localStorage. Briefly speaking, localStorage works somewhat like a database; it stores some pieces of data – key and value – locally on the user's browser, which then can be retrieved using JavaScript API. Unlike Cookie, localStorage is persistent.

Does localStorage work across tabs?

Local Storage Events You might have already used LocalStorage, which is accessible across Tabs within the same application origin. But do you know that it also supports events? You can use this feature to communicate across Browser Tabs, where other Tabs will receive the event once the storage is updated.


1 Answers

  1. If I save data to localStorage, and the user closes the browser, does that data get wiped out? Or is it still accessible when they open up a new browser instance?
  • No, the data are persisted and aren't expired until you remove or clear them.

  • If you want the data removed when the users close the browser use sessionStorage instead.

  • No data persisted in private mode (incognito mode)

  1. Is localStorage data available to all instances of a browser, or does each browser instance (say, for whatever reason, the user has 5 Firefox instances opened) get its own localStorage?
  • It shares data across the instances of a specific browser, for instance, Firefox tabs/instances share the same data but Chrome doesn't share the data with Firefox.

  • It also depends on the browser mechanism:

  • Chrome allows adding users, so tabs belong to one user share the same data.
  • Data in private mode will be cleared after the browser is closed.
  1. When a user flushes all cookies & session data, does localStorage also get wiped out?
  • No, it is only wiped out if you clear localStorage.
like image 61
Quy Tang Avatar answered Sep 29 '22 17:09

Quy Tang