一个帐号在一定的时间里只能登录一次
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();
}
}
{
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();
}
}
相关文章推荐
- debounce函数让一个方法在一定时间内只能执行一次
- Java web开发一个帐号同一时间只能一个人登录
- 一个帐号同一时间只能一个人登录
- 一个帐号同一时间只能一个人登录
- Spring Boot + Spring Security 防止用户在多处同时登录(一个用户同时只能登录一次)及源码分析
- java web中实现同一帐号同一时间只能一个地点登陆(类似QQ登录的功能)
- [转载]一个帐号同一时间只能一个人登录
- 检查一个路径下文件是否存在,如果不存在设置一个定时器,在定时器内每隔一定时间检查一次,直到该文件存在返回成功,或者定时超时返回失败
- java web中实现同一帐号同一时间只能一个地点登陆(类似QQ登录的功能)
- java web中实现同一帐号同一时间只能一个地点登陆(类似QQ登录的功能)
- 一个用户在同一时间只能登录一次
- 一个帐号在同一时间只能一个人登录
- 一个帐号同一时间只能一人登录
- java web开发一个帐号同一时间只能一个人登录
- java web开发一个帐号同一时间只能一个人登录
- java web中实现同一帐号同一时间只能一个地点登陆(类似QQ登录的功能)
- 一定时间内,只能发送一次请求
- [转载] java web开发一个帐号同一时间只能一个人登录
- 一个用户在同一时间只能登录一次
- java web开发一个帐号同一时间只能一个人登录(单点登录)