コード例 #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);
        }