Monday, 9 September 2013

Why do two web pages have different localStorage? How can I fix this?

Why do two web pages have different localStorage? How can I fix this?

I'm trying to pass a value from one page to another using localStorage.
Both pages use a common JS file to get/set values from localStorage. This
page sets the value appropriately using localStorage.setItem('key',
'value'). http://demandbaselabs.com/dnb/index.html ('ip' is parsed from
the query string and written to localStorage with key "db_ip")
When I try to do localStorage.getItem('db_ip') on this page, then the item
is not there: http://www.demandbaselabs.com/dnb/dnb.html
I'm reading specs that say "every Document object whose Window object's
localStorage attribute's Storage object is associated with the same
storage area" (see:
dev.w3.org/html5/webstorage/#the-localstorage-attribute), so this makes me
think pages can have separate localStorage by having a different Storage
object.
I can see the Storage object is different between the two pages...how to I
make both pages use the same Storage object?
Thank you in advance!

No comments:

Post a Comment