简单判断用户重复登录,记录一下

 

Code
//判断用户是否重复登录


string key = TextBox1.Text; //用户名文本框设为cache关键字
string uer = Convert.ToString(Cache[key]); //读取cache中用户相应的值

if (uer == null || uer == String.Empty)
{
//定义cache过期时间
TimeSpan SessTimeout = new TimeSpan(0, 0, System.Web.HttpContext.Current.Session.Timeout, 0, 0);
//第一次登陆的时候插入一个用户相关的cache值,
HttpContext.Current.Cache.Insert(key, key, null, DateTime.MaxValue, SessTimeout, System.Web.Caching.CacheItemPriority.NotRemovable, null);

Session[
"Member "] = TextBox1.Text;

}
else
{
//重复登陆
Response.Write(" <script> alert( '您的账号已经登陆! ');</script> ");
}

简单判断用户在一定的时间内,是否重复登录,将用户的信息作为key值,插入到cache中。 

转载于:https://www.cnblogs.com/suneryong/archive/2008/11/26/1341472.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值