摘自官方文档:,它说:
页面会话持续到“选项卡或浏览器打开”,并且
在页面重新加载和还原上生存。
在新标签中打开页面
或窗口创建一个具有顶级值的新会话
浏览上下文,这与会话cookie的工作方式不同。
打开
具有相同URL的多个标签/窗口为SessionStorage创建
每个选项卡/窗口。
复制一个选项卡副本副本的sessionstorage
进入新标签。
关闭选项卡/窗口结束会话并清除
sessionstorage中的对象。
没有明显的矛盾吗?
关闭选项卡/窗口结束会话并清除SessionStorage中的对象。
同时,
页面会话持续使用,只要打开选项卡或浏览器打开,并且可以通过页面重新加载和还原存活。
我已经使用我的网站测试,该网站将访问令牌存储在SessionStorage中。关闭标签后,我可以从历史记录中还原页面,而无需再次登录。
但是这怎么可能是对的?
当我关闭选项卡时,会话结束并清除会话速度中的对象。
但是,当我从历史记录中恢复时,SessionStorage又回来了???
问题:
-
这不是显而易见的矛盾吗?这怎么可能是对的?
-
关闭选项卡时如何删除SessionStorage对象?它是完整的删除还是仍然保存在某个地方?导致下一个问题:
-
恢复页面并恢复sessionstorage时,数据从哪里恢复?
-
是否有时间限制无法再还原关闭页面/选项卡?
From the official Doc: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage, it states:
A page session lasts as long as the tab or the browser is open, and
survives over page reloads and restores.
Opening a page in a new tab
or window creates a new session with the value of the top-level
browsing context, which differs from how session cookies work.
Opening
multiple tabs/windows with the same URL creates sessionStorage for
each tab/window.
Duplicating a tab copies the tab's sessionStorage
into the new tab.
Closing a tab/window ends the session and clears
objects in sessionStorage.
Isn't there an obvious contradiction?
Closing a tab/window ends the session and clears objects in sessionStorage.
in the meantime,
A page session lasts as long as the tab or the browser is open, and survives over page reloads and restores.
I have tested with my website, which stores access tokens in sessionStorage. After I close the tab, I can restore the page from history and I do not need to sign in again.
But how can this be right?
When I close the tab, the session is ended and objects in sessionStorage are cleared.
But when I restore from history, the sessionStorage is back again???
Questions:
-
Isn't this an obvious contradiction? How can this be right??
-
How does it delete the sessionStorage object when closing the tab? Is it a complete deletion or still saved somewhere? which leads to the next question:
-
When the page is restored and sessionStorage is restored, where is the data restored from?
-
Is there a time limit over which one can no longer restore a closed page/tab?
发布评论