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

  • 相关阅读:
    收藏
    计算矩阵连乘
    关于sublime text
    关于拓扑排序(topologicalsort)
    生成最小树prim算法
    矩阵转置的两种算法
    android wifi热点 socket通信
    AsyncTask异步任务类使用学习
    数据库操作学习
    android 监听短信并发送到服务器
  • 原文地址:https://www.cnblogs.com/kaiwanlin/p/3714302.html
Copyright © 2011-2022 走看看