简体   繁体   English

HTML会话存储范围和寿命

[英]HTML sessionStorage scope and life span

I have read that: 我读过:

The session storage uses the sessionStorage object to store data on a temporary basis, for a single window (or tab). 会话存储使用sessionStorage对象为单个窗口(或选项卡)临时存储数据。 The data disappears when session ends ie when the user closes that window (or tab) 会话结束时,即用户关闭该窗口(或标签)时,数据消失

I have 2 html files stored locally. 我有2个html文件存储在本地。 I populate a session Storage item when File1 is loaded. 加载File1时,我填充了会话存储项。 Without closing the tab I try to open File2 (using browser address bar). 在不关闭选项卡的情况下,我尝试打开File2(使用浏览器地址栏)。 It seems I cannot retrieve the same session Storage item now. 看来我现在无法检索相同的会话存储项。

Is this supposed to work like this? 这应该像这样工作吗? When I move back to the File1 html page, I can still see the value. 当我回到File1 html页面时,仍然可以看到该值。

Why does this happen? 为什么会这样?

If you are using, chrome browser you can open developer to check weather your session storage has saved (also available on other browser) , and also can check weather have share among the tab. 如果您使用的是chrome浏览器,则可以打开开发人员来检查会话存储已保存的天气(在其他浏览器上也可用),还可以检查标签之间的天气是否已共享。

在此处输入图片说明

As my experience, session storage is able to share among the tab, but not recommenced, data may lose once browser crash. 以我的经验,会话存储能够在选项卡之间共享,但不建议您这样做,一旦浏览器崩溃,数据可能会丢失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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