Is there a way to isolate 'localStorage' between different tabs?

爷,独闯天下 提交于 2021-02-05 06:43:06

问题


I am currently using window.localStorage to store some client side data on browser. But I'd like to isolate this storage to individual tabs.

Is there a way to achieve this?


回答1:


You should consider using sessionStorage instead:

sessionStorage is similar to localStorage; the only difference is while data stored in localStorage has no expiration time, data stored in sessionStorage gets cleared when the page session ends. A page session lasts for as long as the browser is open and survives over page reloads and restores. Opening a page in a new tab or window will cause a new session to be initiated with the value of the top-level browsing context [...]



来源:https://stackoverflow.com/questions/56349852/is-there-a-way-to-isolate-localstorage-between-different-tabs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!