Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
65
rated 0 times [  70] [ 5]  / answers: 1 / hits: 20622  / 11 Years ago, tue, september 10, 2013, 12:00:00

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://example.com/path/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.example.com/path/page.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, 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?


More From » html

 Answers
15

The localStorage isin't per page, it's by domain. However like @bfavaretto mentionned, www.demandbaselabs.com and demandbaselabs.com aren't considered as the same domain.



Have a look at this answer to see how you can exchange client-side stored data between domains.


[#75802] Sunday, September 8, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kristinsonjab

Total Points: 364
Total Questions: 98
Total Answers: 98

Location: Christmas Island
Member since Mon, Oct 19, 2020
4 Years ago
kristinsonjab questions
Fri, Mar 4, 22, 00:00, 2 Years ago
Fri, Jan 22, 21, 00:00, 3 Years ago
Fri, Aug 14, 20, 00:00, 4 Years ago
;