Does HTML5 localStorage persist across browser instances?

Viewed 4667

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?
2 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.
Related