zoukankan      html  css  js  c++  java
  • 同一账号禁止多人同时登陆

    首先在Global中写如下代码:

    1. protected void Session_Start(Object sender, EventArgs e)  
    2.  ...{  
    3.  ArrayList lstName=new ArrayList();  
    4.  this.Application.Add("name",lstName);  
    5.  }  
    6.    
    7.  //****************************************************************************************************8  
    8.  protected void Session_End(Object sender, EventArgs e)  
    9.  ...{  
    10.  Application.Lock();  
    11.  string str=Session["name"].ToString();  
    12.  ArrayList lstName=(ArrayList)this.Application["name"];  
    13.  Application.UnLock();  
    14.  }  

    然后在登陆页面写代码
    1. string username=this.txtName.Text.Trim();  
    2.  ArrayList lstName=(ArrayList)this.Application["name"];  
    3.  foreach(string strname in lstName)  
    4.  ...{  
    5.  if(username.Equals(strname))  
    6.  ...{  
    7.  Response.Redirect("User_Login.aspx");  
    8.  }  
    9.  }  
    10.    
    11.  lstName=(ArrayList)Application["name"];  
    12.  lstName.Add(this.txtName.Text.Trim());  
    13.  this.Application.Lock();  
    14.  this.Application["name"]=lstName;  
    15.  Session["name"]=username;  
    16.  this.Application.UnLock();  
    17.  this.Response.Redirect("main.aspx");  
  • 相关阅读:
    2028 ACM Lowest Common Multiple Plus
    2032 杨辉三角
    2011 ACM 0和1思想
    grid
    Change position in observation
    1490 ACM 数学
    1489 ACM 贪心
    2009 ACM 水题
    Book Lending Registration
    MR1和MR2(Yarn)工作原理流程
  • 原文地址:https://www.cnblogs.com/Look_Sun/p/1856695.html
Copyright © 2011-2022 走看看