在子域之间使用localStorage [英] use localStorage across subdomains
本文介绍了在子域之间使用localStorage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I'm replacing cookies with localStorage on browsers that can support it (anyone but IE). The problem is site.com and www.site.com store their own separate localStorage objects. I believe www is considered a subdomain (a stupid decision if you ask me). If a user was originally on site.com and decides to type in www.site.com on her next visit, all her personal data will be inaccessible. How do I get all my "subdomains" to share the same localStorage as the main domain?
推荐答案
这就是我使用它的方式跨域...
This is how I use it across domains...
- 使用父域中的iframe - 比如parent.com
- 然后在每个child.com域上,只需对你的parent.com iframe执行postMessage
- 你需要做的就是设置一个如何解释你的postMessage消息与父母交谈的协议.com iframe。
我希望它有所帮助:)
这篇关于在子域之间使用localStorage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文