string strUserId = txtUser.Text; ArrayList list = Application.Get("GLOBAL_USER_LIST") as ArrayList; if (list == null) { list = new ArrayList(); } for (int i = 0; i < list.Count; i++) { if (strUserId == (list as string)) { //已经登录了,提示错误信息 lblError.Text = "此用户已经登录"; return; } } list.Add(strUserId); Application.Add("GLOBAL_USER_LIST", list); |
void Session_End(object sender, EventArgs e) { // 在会话结束时运行的代码。 // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为 // InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer // 或 SQLServer,则不会引发该事件。 string strUserId = Session["SESSION_USER"] as string; ArrayList list = Application.Get("GLOBAL_USER_LIST") as ArrayList; if (strUserId != null && list != null) { list.Remove(strUserId); Application.Add("GLOBAL_USER_LIST", list); } } |
function window.onbeforeunload() { if (event.clientX>document.body.clientWidth && event.clientY<0||event.altKey) { window.open("logout.aspx"); } } |
var x=0; function myRefresh() { var httpRequest = new ActiveXObject("microsoft.xmlhttp"); httpRequest.open("GET", "test.aspx", false); httpRequest.send(null); x++; if(x<60) //60次,也就是Session真正的过期时间是30分钟 { setTimeout("myRefresh()",30*1000); //30秒 } } myRefresh(); |
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |