非活动期后会话超时 [英] Session timeout after period of inactivity

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

问题描述

我有一个需要登录的应用程序,我也有一个AJAX定时器。我已阅读如何的一段时间后创建一个会话超时几个职位。不过,我想在会议结束,如果用户没有点击时说,5分钟一定的按钮。有没有一种方法来复位定时器每次点击后?

I have an application that requires a login and I also have an AJAX timer. I have read several posts on how to create a session timeout after a certain period of time. However, I want the session to end if the user hasn't clicked a certain button for say, 5 minutes. Is there a way to reset the timer after every click?

推荐答案

试试这个:

function logout() { 
    location.href = '/your/logout/page.aspx';
}

var timeout = setTimeout(300000, logout);
function resetTimeout() {
    clearTimeout(timeout);
    timeout = setTimeout(300000, logout);
}

document.onclick = resetTimeout;

这篇关于非活动期后会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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