IAmYourFaja
IAmYourFaja

Reputation: 56874

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?

Upvotes: 7

Views: 6421

Answers (2)

Quy Tang
Quy Tang

Reputation: 3979

  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.

Upvotes: 6

Bhupendra
Bhupendra

Reputation: 1286

Local Storage is persistant in different tabs/windows when application is opened from same domain. 5MB storage per Domain is provided. LocalStrorage can be wiped only when u remove it manualy by LocalStorage.clear(); For more on info on html5 local storage please visit :LOCALSTORAGE in html5

Upvotes: 4

Related Questions