简体   繁体   中英

Can two different websites interact with each others localstorage

Lets say, I have to websites with completely different domains.

Domain 1 is water.com

Domain 2 is fire.com

If domain 1 (water.com) uses localStorage to store a username, can domain 2 (fire.com) see what that user name is and authenticate with it?

This does not have to be localStorage, I can use cookies as well if they allow the above interaction...

I dont have two domains, rather, I have a chrome extension and a domain that need to interact. IE, if the extension is loged in, so will the domain or vise versa.

What is the best practice to set these cookies/storage variable?

Can you point me to some documentation and and an example?

Thanks you.

I know for sure that you cannot have cross domain cookies for security reasons. I believe the same is true. However your second domain, or extension in your case could redirect to the first and the first could send by the needed information such as credentials.

This question may help you out more:

stackoverflow.com/questions/4177803/...

The link on the correct answer talks about a way to possible share information using XAuth. I don't know too much about that but maybe the link will give you some ideas.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM