c#cookie读取写入操作

public static void SetCookie(string cname, string value, int effective)
        {
            HttpCookie cookie = new HttpCookie(cname);
            cookie.Value = value;
            cookie.Expires = DateTime.Now.AddDays(effective);
            HttpContext.Current.Response.Cookies.Add(cookie);
        }

        public static object GetCookie(string cname)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[cname];
            return cookie;
        }

        public static void RemoveCookie(string name)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[name];
            if (cookie != null)
            {
                cookie.Expires = DateTime.Now.AddDays(-10);
                HttpContext.Current.Response.Cookies.Add(cookie);
            }
        } 
原文地址:https://www.cnblogs.com/feizianquan/p/9709848.html