2

In html5 local storage, I want to know what the local storage is automatically relative to. For example, is it relative to the domain? Is it relative to the user account thats running the browser. Note that I will mainly be using IE 11. So for example if user A is running IE and saves color=red in local cache, then A signs out, and B signs in (on the same physical computer), and runs the browser and tried to retrieve the value of key 'color' from local storage, will they get red or null?

Thanks

omega
  • 40,311
  • 81
  • 251
  • 474

2 Answers2

1

My understanding is that it's browser-instance related (with a few exceptions I'll get to). So the short answer is no, a new user has a new "browser instance", and so the localStorage value should be different*.

Things to consider:

IE11 works in such a manner that, even if you open a new window, it considers it part of the same instance, so localStorage (and cookies) will be shared across different windows. You can stop it from doing this by enabling the "nomerge" setting, which starts a new session/instance of IE every time you open a new window.

Tabs, however, always share localStorage. If you don't want them to, you're better off using sessionStorage, which is tab based and expires when the tab is closed.

*I can't say this with absolute certainty as I can't find windows documentation that states it outright, however it would make little sense if it was shared - localStorage exists so that whatever the user is doing on one tab/window can be accessed on other tabs, so that session data re: login is shared if a user opens a link in a new tab, for instance. It would make for a very strange user experience if you logged onto a website and it suddenly started picking up session data from what another user was doing on there!

Ieuan Stanley
  • 1,248
  • 8
  • 20
  • What if another user runs the browser (i.e. another user account), will local storage be different? (For IE11) – omega Nov 27 '15 at 15:30
  • Like I said, it should be different as it would make no sense to share it and the MSDN documentation on localStorage implies it (https://msdn.microsoft.com/en-us/library/bg142799(v=vs.85).aspx#_global). It uses the terminology of "Domain" there, which implies it has the same scope as Cookies (which would make sense, as I've heard localStorage touted as a modern replacement for Cookies). – Ieuan Stanley Nov 27 '15 at 15:35
-2

It's relative to the domain. But you can have more than one cookie at the same time.

pabloFdz
  • 157
  • 1
  • 11