如何判断用户登陆超时? 假如1分钟没有操作就超时,然后提醒一下,怎么实现呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 首先,你要说明白你的提醒是干什么用的?重新登录?还是怎么样?如果需要重新登录,那就没必要检测了,直接设置session有效期就是了如果是其他的,就用js来进行吧 就是提醒过期了,alert("Timeout");我的问题不知道如何捕获一分钟不操作就过期——即:通过怎么样的代码得知用户1分钟没有操作? 超时设置 <sessionState mode="InProc" timeout="60" />GLOBAL.ASAX 中去判断 SESSION_END() 和 PreRequestExcute session? cookie? form 验证? session和js给你一段代码,自己试一下. private void CheckSessionTimeout() { string msgSession = "Warning: Within next 3 minutes, if you do not do anything, " + "our system will redirect to the login page. Please save changed data."; //time to remind, 3 minutes before session end int int_MilliSecondsTimeReminder = (this.Session.Timeout * 60000) - 3 * 60000; //time to redirect, 5 miliseconds before session end int int_MilliSecondsTimeOut = (this.Session.Timeout * 60000) - 5; string str_Script = @"var myTimeReminder, myTimeOut; clearTimeout(myTimeReminder);clearTimeout(myTimeOut); " + "var sessionTimeReminder = " + int_MilliSecondsTimeReminder.ToString() + "; " + "var sessionTimeout = " + int_MilliSecondsTimeOut.ToString() + ";" + "function doReminder(){ alert('" + msgSession + "'); }" + "function doRedirect(){ window.location.href='login.aspx'; }" + @"myTimeReminder=setTimeout('doReminder()', sessionTimeReminder); myTimeOut=setTimeout('doRedirect()', sessionTimeout); "; ClientScript.RegisterClientScriptBlock(this.GetType(), "CheckSessionOut", str_Script, true); } private void Page_Load(object sender, System.EventArgs e){ this.CheckSessionTimeout();} 楼主说:我的问题不知道如何捕获一分钟不操作就过期——即:通过怎么样的代码得知用户1分钟没有操作?有必要自己去跟踪用户多长时间没有操作吗?设置session过期值,让系统给你判断好了。 设置session过期时间为一分钟,判断session是否为 null或查询用户操作日志,超过一分钟操作,设置用户没登录。 MYSQL 语法错了..帮我看看 急 高分求助:关于ASP.Net AJAX的问题 Repeater输出的内容如何实现自动对齐 这确实是个问题:关于关闭子窗口刷新父窗口的问题 一个页面include次数太多,是否影响性能? 如何将查出来的数据转成表二 在MSN中添加联系人时候,我怎么知道这个联系人现在当前是在线的??? 有关数组的问题,不解,求助,在线 ASP。NET中如何3秒中重定向 在asp.net中如何实现文件的包含? 如何调用母版页函数 关于javascript的
GLOBAL.ASAX 中去判断 SESSION_END() 和 PreRequestExcute
给你一段代码,自己试一下.
private void CheckSessionTimeout()
{
string msgSession = "Warning: Within next 3 minutes, if you do not do anything, " +
"our system will redirect to the login page. Please save changed data.";
//time to remind, 3 minutes before session end
int int_MilliSecondsTimeReminder = (this.Session.Timeout * 60000) - 3 * 60000;
//time to redirect, 5 miliseconds before session end
int int_MilliSecondsTimeOut = (this.Session.Timeout * 60000) - 5; string str_Script = @"var myTimeReminder, myTimeOut; clearTimeout(myTimeReminder);clearTimeout(myTimeOut); " +
"var sessionTimeReminder = " + int_MilliSecondsTimeReminder.ToString() + "; " +
"var sessionTimeout = " + int_MilliSecondsTimeOut.ToString() + ";" +
"function doReminder(){ alert('" + msgSession + "'); }" +
"function doRedirect(){ window.location.href='login.aspx'; }" +
@"myTimeReminder=setTimeout('doReminder()', sessionTimeReminder); myTimeOut=setTimeout('doRedirect()', sessionTimeout); "; ClientScript.RegisterClientScriptBlock(this.GetType(),
"CheckSessionOut", str_Script, true);
} private void Page_Load(object sender, System.EventArgs e)
{
this.CheckSessionTimeout();
}
或查询用户操作日志,超过一分钟操作,设置用户没登录。