在JavaScript中检查会话超时 [英] Checking Session Timeout in JavaScript

查看:78
本文介绍了在JavaScript中检查会话超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过javaScript检查会话是否超时?如果可以使用javascript,有人可以帮助我处理代码段吗?

Is there any way to check by javaScript whether a session is timeout? If it is possible in javascript, can any one help me with the code snippet?

推荐答案

如果JavaScript ping服务器,它将刷新会话.因此,它不能只是调用和检查.通常使用在客户端上运行一定时间的计时器来完成此操作.如果计时器触发,您知道会话可能已过期.

If JavaScript pings the server, it will refresh the session. So it can not just call and check. It is normally done with a timer on the client that runs for a length of time. If the timer fires you know the session may be expired.

如果用户使用多个窗口,计时器将失败.在这种情况下,您需要运行带有localstorage/cookie的内容,以说出上次服务器被击中的时间.

The timer would fail if the user is using multiple windows. In that case you would need to run something with localstorage/cookies to say when the last time the server was hit.

这篇关于在JavaScript中检查会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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