您如何显示足够智能以处理多个打开的浏览器或选项卡的会话超时警告 [英] How can you display a session timeout warning that is smart enough to handle multiple open browsers or tabs

查看:53
本文介绍了您如何显示足够智能以处理多个打开的浏览器或选项卡的会话超时警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 javascript 实现了会话超时警告,它只是询问用户是否要延长会话或注销.问题在于,这是针对内部网门户,其中高级用户通常会同时向应用程序打开多个浏览器窗口或选项卡.目前,系统会提示他们即将从每个浏览器窗口注销.如何让代码更智能地检测到他们正在积极使用另一个浏览器会话?

I have implemented a session timeout warning using javascript that simply asks the user if they want to extend their session or logout. The problem is that this is for an intranet portal where power users will often have several browser windows or tabs open at the same time to the application. Currently, they will be prompted that they are about to be logged out from every browser window. How can I make the code smarter to detect that they are actively using another browser session?

推荐答案

您不能指望所有选项卡/窗口都属于同一个会话,因为它们可能会生成并包含在单独的进程中,而您不会对此有很大的控制权.

You can't count on all tabs/windows to be part of the same Session, because they could be spawned and contained within separate processes and you don't have much control over that.

但如果您的代码引用了 Javascript cookie,您可以通过回发(同步或异步 AJAX)检查您的伪会话状态.但是,您依赖于在用户浏览器上启用的 cookie.

But if your code references a Javascript cookie, you can check your pseudo-session state via a postback (synchronous or asynchronous AJAX). But then you're depending on cookies being enabled on the user's browser.

这篇关于您如何显示足够智能以处理多个打开的浏览器或选项卡的会话超时警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆