亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

asp.net 簡(jiǎn)單單點(diǎn)登錄技術(shù)分析

 更新時(shí)間:2011年02月14日 21:58:05   作者:  
單點(diǎn)登錄,又叫SSO(Single Sign On)。在一些cms或者OA中比較常用到這種登錄模式,目的是為防止重復(fù)登錄。而其實(shí)現(xiàn)原理也頗為簡(jiǎn)單,只要Cache的形式就可以實(shí)現(xiàn),這里只用于簡(jiǎn)單記錄下,呵呵……
代碼如下:
復(fù)制代碼 代碼如下:

///單點(diǎn)登錄(Single Sign On)
public void SSOMethods(string username, string password)
{
//判斷登錄情況 此處方法省略……
int result = CheckLogin(username, password);
if(result>0)
{
//唯一標(biāo)識(shí),可自行設(shè)定
string key = string.Format("{0}_{1}",username, password);
//得到Cache中的key值
string userCache = Cache[key].ToString();
//判斷是否為空
if(string.IsNullOrEmpty(userCache))
{
TimeSpan SessionTimeOut = new TimeSpan(0,0,HttpContext.Current.Session.TimeOut,0,0);
HttpContext.Current.Cache.Insert(key,key,null,DateTime.MaxValue,SessionTimeOut,CacheItemPriority,NotRemovable,null);
Session["User"] = key;
Response.Write("<font color=red>登錄成功!</font>");
}
else
{
Repsonse.Write("<font color=red>抱歉,您已經(jīng)在其他地方登錄了!</font>");
return;
}
}
else
{
Response.Write("用戶名不存在!");
}
}

相關(guān)文章

最新評(píng)論