原文:Sharing sessionStorage between tabs for secure multi-tab authentication
使用场景
在web项目中,当用户重开一个标签页的时候,需要重新登录。造成这种情况的是登录的标识符存取在session中,标签页之间没有共享session数据。
解决方式
发现国外开发者解决的方式是监听storage事件,利用localStorage事件来跨标签页共享sessionStorage。
在线例子
1 | // Removed IE support in this demo for the sake of simplicity |