http 和 https 的本地存储相同吗?
http:// example .com 和
https:// example .com 使用相同的 localStorage (或类似的)
我正在寻找一种方法,根据 a href="https://developer.mozilla.org/En/DOM/Storage#localStorage" rel="noreferrer">这个,使用 localStorage 是不可能的。不过,chrome 似乎没有 globalStorage
。 我正在为 chrome 扩展程序执行此操作,因此不能选择使用 cookie,并且不需要与其他浏览器兼容。
有什么想法吗?
i'm looking for a way to use the same localStorage (or similar) for both http:// example .com
and https:// example .com
according to this, that's not possible using localStorage. there doesn't seem to be a globalStorage
for chrome though.
i'm doing this for a chrome extension, so using cookies is not an option and compatibility with other browsers is not needed.
any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您需要的只是将网站上花费的时间存储在 localStorage 中,那么您不需要解决此 http/https 问题。扩展有自己独立的本地存储,您可以随时随地访问,因此只需将数据存储在那里即可。
您只能从后台页面访问此 localStorage,因此您需要首先从内容脚本向后台页面发送请求,然后在其中使用 localStorage:
content_script.js:
background .html:
If all you need is store time spent on the site in localStorage then you don't need to solve this http/https problem. Extensions have their own isolated localStorage that you can access anytime anywhere, so just store your data there.
You can access this localStorage only from a background page, so from a content script you will need to send a request to a background page first and then work with localStorage there:
content_script.js:
background.html: