简单判断用户重复登录,记录一下
生活随笔
收集整理的這篇文章主要介紹了
简单判断用户重复登录,记录一下
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
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
總結
以上是生活随笔為你收集整理的简单判断用户重复登录,记录一下的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 晶闸管整流电路
- 下一篇: error LNK2019: unres