码迷,mamicode.com
首页 > 其他好文 > 详细

单点登录

时间:2014-05-08 12:18:20      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:tar   ext   get   http   c   string   

string sKey = username.Text.ToString().Trim(); // 得到Cache中的给定Key的值
            string sUser = Convert.ToString(Cache[sKey]); // 检查是否存在
            if (sUser == null || sUser == String.Empty)
            {
                
                TimeSpan SessTimeOut = new TimeSpan(0, 0, System.Web.HttpContext.Current.Session.Timeout, 0, 0);//取得Session的过期时间
                HttpContext.Current.Cache.Insert(sKey, sKey, null, DateTime.MaxValue, SessTimeOut, System.Web.Caching.CacheItemPriority.NotRemovable, null);//将值放入cache己方便单点登录
              //成功登录
            }
            else if (Cache[sKey].ToString() == sKey)//如果这个账号已经登录
            {
                ClientScript.RegisterStartupScript(GetType(), "提示", "<script>alert(‘对不起,当前用户已经登录‘);</script>");
                return;
            }
            else
            {
                Session.Abandon();//这段主要是为了避免不必要的错误导致不能登录
            }

单点登录,布布扣,bubuko.com

单点登录

标签:tar   ext   get   http   c   string   

原文地址:http://www.cnblogs.com/kaiwanlin/p/3714302.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!