终止和启动时 Safari 本地存储为空
我正在向 Safari 的本地存储写入一个简单的值,如果 Safari 关闭,它将能够读取有问题的值。
有趣的是,我可以使用以下代码将数据写入本地存储:
localStorage.setItem("savedData", JSON.stringify(cookieValue));
但是当我关闭 Safari 的所有实例并打开一个新实例时,本地存储显示为空。
有谁知道为什么会发生这种情况?
I am writing a simple value to Safari's local storage, if Safari is then shut down it will be able to read the value in question.
Interestingly I am able to write the data to local storage with the following code:
localStorage.setItem("savedData", JSON.stringify(cookieValue));
But when I close all instances of Safari and open a new one the local storage is shown as empty.
Does anybody know why this would happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案相当明显,这是我忽略了一些更精细的细节的错误;本质上,浏览器试图使安全数据远离不安全数据。
尝试存储数据的页面是http,而尝试检索数据的页面是https。
来自 Mozilla - DOM 存储
我假设这个概念适用于所有浏览器,那么它又是只是一个假设。
希望这对可能处于相同情况的人有所帮助。
The solution is rather obvious, it was my mistake from omitting some of the finer details; essentially the browser is trying to keep the secure data away from the insecure data.
The page that tries to store the data is http, whereas the page that tries to retrieve the data is https.
From Mozilla - DOM Storage
I'm assuming this concept applies to all browsers, then again it's only an assumption.
Hope this helps people who may be in the same situation.