Esempio n. 1
0
 internal SessionManager(ISessionSet sessionSet,
                         PersonFetchHandler personFetchHandler, string seed)
 {
     this._sessionSet         = sessionSet;
     this._personFetchHandler = personFetchHandler;
     this._generator          = new SessionGenerator(seed, 5);
 }
Esempio n. 2
0
        /// <summary>
        /// 保存会话,并返回Session Value
        /// </summary>
        /// <param name="personId"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public string SaveSession(int personId)
        {
            string sessionKey   = SessionGenerator.CreateKey();
            string sessionToken = String.Format("{0:yyyyMMHHssfff}", DateTime.Now);

            string usrKey = "sk_" + personId.ToString();

            //获取上次的Session记录并删除
            string usrKeyValue = this._sessionSet.Get(usrKey);

            if (!String.IsNullOrEmpty(usrKeyValue))
            {
                this._sessionSet.Delete(usrKeyValue);
            }

            //保存新的Session记录
            this._sessionSet.Put(usrKey, sessionKey);
            this._sessionSet.Put(sessionKey, personId.ToString() + ";" + sessionToken);


            HttpCookie cookie = new HttpCookie(Variables.SessionCookieName, sessionKey);

            cookie.Expires = DateTime.Now.AddYears(2);

            HttpContext.Current.Response.Cookies.Add(cookie);

            return(sessionToken);
        }
Esempio n. 3
0
 internal SessionManager(ISessionSet sessionSet,
     PersonFetchHandler personFetchHandler,string seed)
 {
     this._sessionSet = sessionSet;
     this._personFetchHandler = personFetchHandler;
     this._generator = new SessionGenerator(seed,5);
 }