Reputation: 183
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 www.example.com be shared with a similar approach?
Many thanks in advance
Upvotes: 2
Views: 2233
Reputation: 115950
That should not happen.
Are you absolutely sure they have the same origin? They must have the same:
Subdomains: http://example.com
and http://www.example.com
are different origins
Protocols: http://www.example.com
and https://www.example.com
are different origins
Alternatively, it's possible that localStoarge
might be full, so new data is getting silently ignored.
If you are doing development locally, make sure you do not intermix localhost
and 127.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 with file://
), browsers may treat each file:
URL as a distinct origin, or at least treat different directories as different origins.
Upvotes: 4