コード例 #1
0
 //更新用户的cookie
 public static void CreateCookie(User user)
 {
     try
     {
         var obj = CryptoHelper.AES_Encrypt(user.ToJson(), Params.SecretKey);
         HttpContext.Current.Session[Params.UserCookieName] = obj;
     }
     catch (Exception ex) {
         LogHelper.WriteException(ex);
     }
 }
コード例 #2
0
 //更新用户的cookie
 public static void CreateCookie(User user)
 {
     try
     {
         HttpCookie cookie = new HttpCookie(Params.UserCookieName);
         cookie.Value   = CryptoHelper.AES_Encrypt(user.ToJson(), Params.SecretKey);
         cookie.Expires = DateTime.Now.AddMinutes(Params.CookieExpires);
         // 写登录Cookie
         HttpContext.Current.Response.Cookies.Remove(cookie.Name);
         HttpContext.Current.Response.Cookies.Add(cookie);
     }
     catch (Exception ex) {
         LogHelper.WriteException(ex);
     }
 }