コード例 #1
0
 public static string GetOpenId(UserCookie userCookie, string apppId)
 {
     if (userCookie == null || userCookie.OpenIds == null || !userCookie.OpenIds.ContainsKey(apppId))
     {
         return(null);
     }
     return(userCookie.OpenIds[apppId]);
 }
コード例 #2
0
        public static UserCookie GetCookie()
        {
            var        userCookie = new UserCookie();
            HttpCookie cookie     = HttpContext.Current.Request.Cookies[_cookieName];

            if (cookie != null && !string.IsNullOrWhiteSpace(cookie.Value))
            {
                var value = CryptographyHelper.AESDecrypt(cookie.Value);
                userCookie = SerializeHelper.Deserialize <UserCookie>(value);
            }
            return(userCookie);
        }
コード例 #3
0
 public static void SetCookie(UserCookie userCookie)
 {
     if (userCookie != null)
     {
         var cookieValue = CryptographyHelper.AESEncrypt(SerializeHelper.Serialize(userCookie));
         var cookie      = new HttpCookie(_cookieName, cookieValue)
         {
             Expires  = DateTime.Now.AddDays(7),
             HttpOnly = true
         };
         HttpContext.Current.Response.Cookies.Add(cookie);
         HttpContext.Current.Request.Cookies.Remove(_cookieName);
         HttpContext.Current.Request.Cookies.Add(cookie);
     }
 }