我们可以使用其他域中的localStorage的值吗

问题描述:

我正在一个域中的本地存储中存储一个值,比方说www.abc.com.如果我从同一浏览器访问两个域,是否可以从其他域(www.pqr.com)检索该值.

I am storing a value in local Storage in one domain let say www.abc.com. Can i retrieve that value from other domain(www.pqr.com) if i am accessing both domain from same browser.

否,您不能将一个域的本地存储用于另一个域.本地存储基于域.您不能从位于不同域的本地存储中进行读取或写入,即使在其子域中也是如此.您可以通过子域上的iframe使用它.请仔细阅读本文跨域LocalStorage 以获得详细信息解释.

No, you can't use the local storage of one domain to other domain. Local Storage is domain based. You can’t read or write from localstorage that’s on different domain even on it's subdomain. you can use it via Iframe on your subdomain. Please go through this article Cross-Domain LocalStorage for detailed explanation.

希望会有所帮助.:)