您的位置:首页 > 其它

一个帐号在一定的时间里只能登录一次

2006-09-25 13:25 330 查看
protected void btLogic_Click(object sender, EventArgs e)
{
c.userName = txtName.Value;
c.PWD = txtPWD.Value;
if(Convert.ToInt32( BusinessDAL.CheckUser(c))==1)
{
//Session["userName"] = txtName.Value;
//Session.Timeout = 100;
CheckLogic();
Response.Redirect("Default.aspx");
}
else
{
Response.Write("<script>alert('输入有误请重新输入');window.location.href='logic.aspx'</script>");
}

}

/// <summary>
/// 一个帐号在一定的时间里只能登录一次
/// </summary>
public void CheckLogic()
{
string strUser = string.Empty;
string cahStrKey = this.txtName.Value;
strUser = Convert.ToString(Cache[cahStrKey]);

if (strUser == string.Empty)
{//表示还没有登录
// Session["userName"] = txtName.Value;
Session.Timeout = 100;
TimeSpan timeOut = new TimeSpan(0,0,Session.Timeout);
Cache.Insert(cahStrKey, cahStrKey, null, DateTime.MaxValue, timeOut, CacheItemPriority.NotRemovable, null);
Session["userName"] = cahStrKey;
Response.Write(Session["userName"].ToString());
}

else
{

Response.Write("你已经登录"+"<script language='javascript'>window.location.href='Default.aspx';</script>");
Response.End();
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: