Why do two web pages have different local storage? How can i fix this?

I am 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 accordingly using localStorage.setItem('key', 'value') : http://demandbaselabs.com/dnb/index.html

ip parsed from the query string and written to localStorage using the db_ip key.

When I try to make localStorage.getItem('db_ip') on this page, then there is no element: http://www.demandbaselabs.com/dnb/dnb.html

I read specifications that say "every Document object whose Local object attribute of the LocalStorage object of the storage object is associated with the same storage area" , so this makes me think that pages can have a separate localStorage, having a different Storage object.

I see that the Storage object is different between the two pages. How to force both pages to use the same storage object?

+6
source share
1 answer

localStorage isin't on the page, this is the domain. However, as @bfavaretto mentioned, www.demandbaselabs.com and demandbaselabs.com are not considered the same domain.

See this answer to find out how you can exchange client-side stored data between domains.

+8
source

Source: https://habr.com/ru/post/953528/


All Articles