문제

I need a client-sided domain-wide way to store a string that is accessible after the page has been closed and reopened. I tried localStorage, but if I store data on www.example.com, I cannot access it from sub.example.com. In this case, redirecting the user to the root host is not an option. I'd really prefer to not send messages to an iframe to store it because it would require completely rewriting the current code I have. Is there a way to store data with something like localStorage, but access it from other subdomains?

My goal is to have two simple functions, get() and set(value), that operate similar to how I've described.

올바른 솔루션이 없습니다

다른 팁

Try storing the data in a cookie, and ensure the cookie is configured to support subdomains.

For example, ".example.com", with the leading ".", will make the cookie available to all subdomains.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top