The invention discloses a method for sharing data Duke groups among multiple label pages. The method comprises the following steps: step 1: when a new label page is opened, whether a label exists, if it exists, the departure time notifies the existing label; step 2: the existing label receives the notification described in step 1, and then detects the item Step 3: According to the result of step 2, if token exists, put token into the local storage trigger event to notify the newly opened tag and remove the token; if not, do not operate; Step 4: Open the new tag, receive the event notification, and get token to put Enter sessionStorage. Storing token in the front-end releases server pressure, and using session Storage to store token tabs can be removed by closing them. It does not survive for a certain period of time when the tabs are closed (or even the browser is completely closed). There is no intermediate state for sharing session Storage between multiple tabs.
【技术实现步骤摘要】
一种多个标签页之间共享数据duke组的方法
本专利技术属于计算机软件
,具体涉及一种多个标签页之间共享数据duke组的方法。
技术介绍
一些重要的系统会要求当用户关闭标签页时会话立刻到期,这些问题就使得我们在保存认证token时应使用内存或sessionStorage。sessionStorage的好处是它允许跨多个页面保存数据,并且也支持浏览器刷新操作。这样用户就可以在多个页面之间跳转或刷新页面而保持登录状态,我们将token保存在sessionStorage,并在每次请求服务器时将token放在请求头中来完成用户的身份认证。当用户关闭标签页,token会立即过期,但是sessionStorage不支持跨标签页共享数据,这就导致了一个很差的用户体验问题,用户经常希望打开多个标签页,因为Token信息是保存在SessionStorage中,所以每次开启一个标签页都会要求用户重新登录。
技术实现思路
本专利技术的目的在于:为了解决上述的用户在使用网页时每打开一个新的标签都会提示用户重新登录的问题,提出一种多个标签页之间共享数据duke组的方法。本专利技术采用的技术方案如下:一种多个标签页之间共享数据duke组的方法,所述方法包括如下步骤:步骤1:当打开新标签页的时候,检测是否存在标签,若存在则出发时间通知已存在标签;步骤2:已存在标签收到步骤1所述的通知,然后检测目前标签页的sessionStorage中是否存在token;步骤3:根据步骤2的检测结果,若token存在则将token放入localstorage触发事件通知新打开的标签并且移除放入的toke ...
【技术保护点】
1.一种多个标签页之间共享数据duke组的方法,其特征在于,所述方法包括如下步骤:步骤1:当打开新标签页的时候,检测是否存在标签,若存在则出发时间通知已存在标签;步骤2:已存在标签收到步骤1所述的通知,然后检测目前标签页的sessionStorage中是否存在token;步骤3:根据步骤2的检测结果,若token存在则将token放入localstorage触发事件通知新打开的标签并且移除放入的token;若不存在则不做操作;步骤4:打开新的标签,接到事件通知,拿到token放入sessionStorage。
【技术特征摘要】
1.一种多个标签页之间共享数据duke组的方法,其特征在于,所述方法包括如下步骤:步骤1:当打开新标签页的时候,检测是否存在标签,若存在则出发时间通知已存在标签;步骤2:已存在标签收到步骤1所述的通知,然后检测目前标签页的sessionStorage中是否存在token;步骤3:根据步骤2的检测结果,若token存在则将token放入localstorage触发事件通知新打开的标签并且移除放入的token;若不存在则不做操作;步骤4:打开新的标签,接到事件通知,拿到token放入sessionStorage。2.根据权...
【专利技术属性】
技术研发人员:刘杰,吴洁慧,都柯,
申请(专利权)人:成都优易数据有限公司,
类型:发明
国别省市:四川,51
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。