zoukankan      html  css  js  c++  java
  • 单点登录

    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();//这段主要是为了避免不必要的错误导致不能登录
                }

  • 相关阅读:
    我对管理信息系统定位的理解
    正斜杠和反斜杠-windows、web、c语言大讨论
    java异常处理的两种方法
    使用throws抛出异常
    课后作业
    每日自学
    《梦断代码》读后感
    每日自学
    每日自学
    每日自学
  • 原文地址:https://www.cnblogs.com/kaiwanlin/p/3714302.html
Copyright © 2011-2022 走看看