Exemple #1
0
        /// <summary>
        /// 设置Cookie变量
        /// </summary>
        /// <param name="key">Cookie变量名</param>
        /// <param name="value">Cookie变量值</param>
        /// <param name="httpOnly">是否只能服务器端访问</param>
        public static void SetValue(String key, String value, Boolean httpOnly)
        {
            HttpCookie cookie = new HttpCookie(key, value);

            cookie.HttpOnly = httpOnly;

            Cookies.SetCookie(cookie);
        }
Exemple #2
0
        /// <summary>
        /// 设置Cookie变量
        /// </summary>
        /// <param name="key">Cookie变量名</param>
        /// <param name="value">Cookie变量值</param>
        /// <param name="expires">Cookie生存时间</param>
        public static void SetValue(String key, String value, DateTime expires)//重载
        {
            HttpCookie cookie = new HttpCookie(key, value);

            cookie.Expires = expires;

            Cookies.SetCookie(cookie);
        }
Exemple #3
0
 /// <summary>
 /// 删除Cookie变量
 /// </summary>
 /// <param name="cookie">Cookie变量</param>
 public static void Remove(HttpCookie cookie)
 {
     if (cookie != null)
     {
         cookie.Expires = DateTime.Now.AddDays(-1);
         Cookies.SetCookie(cookie);
     }
 }
Exemple #4
0
        /// <summary>
        /// 设置Cookie变量
        /// </summary>
        /// <param name="key">Cookie变量名</param>
        /// <param name="value">Cookie变量值</param>
        /// <param name="httpOnly">是否只能服务器端访问</param>
        /// <param name="expires">Cookie生存时间</param>
        public static void SetValue(String key, String value, Boolean httpOnly, DateTime expires)
        {
            HttpCookie cookie = new HttpCookie(key, value);

            cookie.HttpOnly = httpOnly;
            cookie.Expires  = expires;

            Cookies.SetCookie(cookie);
        }
Exemple #5
0
        /// <summary>
        /// 设置Cookie变量
        /// </summary>
        /// <param name="key">Cookie变量名</param>
        /// <param name="value">Cookie变量值</param>
        public static void SetValue(String key, String value)
        {
            HttpCookie cookie = new HttpCookie(key, value);

            Cookies.SetCookie(cookie);
        }