示例#1
0
        /// <summary>
        /// 设置COOKIE
        /// </summary>
        /// <param name="key">cookie键</param>
        /// <param name="TCookie">cookie值</param>
        /// <param name="expires">过期时间,分钟为单位,默认一天</param>
        /// <param name="encrypt">是否加密cookie</param>
        public static void SetCookie <T>(string key, T TCookie, int expires = 1440, bool encrypt = true)
            where T : class, new()
        {
            string json = SerializeHelper.SerializeToJson(TCookie);

            WebHelper.SetCookie(key, json, expires, encrypt);
        }
示例#2
0
        /// <summary>
        /// 设置COOKIE
        /// </summary>
        /// <param name="key">cookie键</param>
        /// <param name="cookie">cookie值</param>
        /// <param name="expires">过期时间,分钟为单位,默认一天</param>
        /// <param name="encrypt">是否加密cookie</param>
        public static void SetCookie <T>(string key, T cookie, DateTime expires, bool encrypt = true)
            where T : class, new()
        {
            string json = SerializeHelper.SerializeToJson(cookie);

            WebHelper.SetCookie(key, json, expires, encrypt);
        }
示例#3
0
        // 此文件适用于 fx(net40,net45)

        #region Cookie

        /// <summary>
        /// 设置Cookie
        /// </summary>
        /// <param name="key">cookie键</param>
        /// <param name="value">cookie值</param>
        /// <param name="expires">过期时间,分钟为单位,默认一天</param>
        /// <param name="encrypt">是否加密cookie</param>
        public static void SetCookie(string key, string value, int expires = 1440, bool encrypt = true)
        {
            WebHelper.SetCookie(key, value, DateTime.Now.AddMinutes(expires));
        }