实现的不让同一个用户登陆

string test = "username";
private void Page_Load(object sender, System.EventArgs e)
{
   if(Application["User_" + test] == null || Application["User_" + test].ToString() != Request.UserHostAddress)
      Session["login"] = null;
   else
      Response.Write(Session["login"].ToString() + "已登录<br>");
}
private void Button1_Click(object sender, System.EventArgs e)
{
   Session["login"] = test;
   Application["User_" + test] = Request.UserHostAddress;
}

你可能感兴趣的:(用户)