Ejemplo n.º 1
0
        public static void Set(string cookieName, string cookieValue, System.DateTime?cookieTime, string domain, string path)
        {
            if (Cookies.Get(cookieName).Length > 0)
            {
                Cookies.Remove(cookieName);
            }
            HttpCookie httpCookie = new HttpCookie(cookieName)
            {
                Value = cookieValue
            };

            if (domain != null)
            {
                httpCookie.Domain = domain;
            }
            if (path != null)
            {
                httpCookie.Path = path;
            }
            if (cookieTime.HasValue)
            {
                httpCookie.Expires = cookieTime.Value;
            }
            //TODO:  设置 sql 总条数为 httpOnly 属性为 true
            if (cookieName.IndexOf("Count") >= 0)
            {
                httpCookie.HttpOnly = true;
            }
            HttpContext.Current.Response.Cookies.Add(httpCookie);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 移除Cookie
 /// </summary>
 /// <param name="cookieName">Cookie Name</param>
 public static void Remove(string cookieName)
 {
     Cookies.Remove(cookieName, null);
 }