예제 #1
0
파일: CookieHelper.cs 프로젝트: like-stop/1
        /// <summary>
        /// 写cookie值
        /// </summary>
        /// <param name="strName">名称</param>
        /// <param name="strValue">值</param>
        public static void WriteCookie(string strName, string strValue, bool isEncrypt)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[strName];

            if (cookie == null)
            {
                cookie = new HttpCookie(strName);
            }
            if (isEncrypt)
            {
                cookie.Value = AESEncryptHelper.Encrypt(strValue);
            }
            else
            {
                cookie.Value = strValue;
            }
            HttpContext.Current.Response.AppendCookie(cookie);
        }
예제 #2
0
파일: CookieHelper.cs 프로젝트: like-stop/1
        /// <summary>
        /// 写cookie值
        /// </summary>
        /// <param name="strName">名称</param>
        /// <param name="strValue">值</param>
        /// <param name="strValue">过期时间(分钟)</param>
        public static void WriteCookie(string strName, string strValue, int expires, bool isEncrypt)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[strName];

            if (cookie == null)
            {
                cookie = new HttpCookie(strName);
            }
            if (isEncrypt)
            {
                cookie.Value = AESEncryptHelper.Encrypt(strValue);
            }
            else
            {
                cookie.Value = strValue;
            }
            if (expires != 0)
            {
                cookie.Expires = DateTime.Now.AddMinutes(expires);
            }
            HttpContext.Current.Response.AppendCookie(cookie);
        }