I am making a mobile web application in backbone under:
http://example.com/mobile/index/
After the user logs in I’m storing a token in localStorage and redirecting to a search route within backbone:
http://example.com/mobile/index/search
I was under the impression the localStorage information can be shared across the entire domain but the localStorage token is only accessible from the latter URL. Why is this not the case? How can I share localStorage for the entire example.com domain?
A side-point if anyone know – will information for m.example.com, example.com and http://www.example.com be shared with a similar approach?
Many thanks in advance
That should not happen.
Are you absolutely sure they have the same origin? They must have the same:
Subdomains:
http://example.comandhttp://www.example.comare different originsProtocols:
http://www.example.comandhttps://www.example.comare different originsAlternatively, it’s possible that
localStoargemight be full, so new data is getting silently ignored.If you are doing development locally, make sure you do not intermix
localhostand127.0.0.1(those a different origins that happen to refer to the same physical machine).If you are doing development locally and loading your page as a
file:resource (i.e., the URL actually starts withfile://), browsers may treat eachfile:URL as a distinct origin, or at least treat different directories as different origins.