コード例 #1
0
        /// <summary>
        /// 删除加密后的cookie
        /// </summary>
        /// <param name="cookiename">明文cookie名</param>
        public static void DelEdCookie(string cookiename)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[HttpUtility.UrlEncode(Md5Helper.Encode(cookiename))];

            if (cookie != null)
            {
                cookie.Expires = DateTime.Now.AddYears(-3);
                HttpContext.Current.Response.Cookies.Add(cookie);
            }
        }
コード例 #2
0
 /// <summary>
 /// 存储加密后的cookie(双加密)
 /// </summary>
 /// <param name="cookiename">明文cookie名</param>
 /// <param name="cookievalue">明文cookie值</param>
 public static string AddEnCookieAndReturn(string cookiename, string cookievalue)
 {
     SetCookie(HttpUtility.UrlEncode(Md5Helper.Encode(cookiename)), HttpUtility.UrlEncode(Md5Helper.Encode(cookievalue)), DateTime.Now.AddDays(1.0));
     return(HttpUtility.UrlEncode(Md5Helper.Encode(cookievalue)));
 }
コード例 #3
0
 /// <summary>
 /// 获取解密后的cookie的值
 /// </summary>
 /// <param name="cookiename">明文cookie名</param>
 /// <returns>解密后的cookie值</returns>
 public static string GetDeCookie(string cookiename)
 {
     return(Md5Helper.Decode(HttpUtility.UrlDecode(GetCookieValue(HttpUtility.UrlEncode(Md5Helper.Encode(cookiename))))));
 }
コード例 #4
0
 /// <summary>
 /// 存储加密后的cookie(双加密)
 /// </summary>
 /// <param name="cookiename">明文cookie名</param>
 /// <param name="cookievalue">明文cookie值</param>
 public static void AddEnCookie(string cookiename, string cookievalue, DateTime expires)
 {
     SetCookie(HttpUtility.UrlEncode(Md5Helper.Encode(cookiename)), HttpUtility.UrlEncode(Md5Helper.Encode(cookievalue)), expires);
 }