HttpCookie cookie = new HttpCookie("user");
//给cookie赋值
cookie.Value = "test";
//如果多个字符赋值
cookie["sex"] = "男";
//或者
cookie.Values.Add("age","30");
//控制cookie有效日期
cookie.Expires = DateTime.Now.AddHours(1);
//发送cookie
Response.AppendCookie(cookie);
//或者
Response.Cookies.Add(cookie);
//读取cookie
HttpCookie cookieRead = Request.Cookies["user"];
//删除cookie
cookie.Expires = DateTime.Now.AddHours(-1);
//跨域读取cookie
cookie.Domain = "wty.demo.com";
cookie.Domain = "support.demo.com";
//给cookie赋值
cookie.Value = "test";
//如果多个字符赋值
cookie["sex"] = "男";
//或者
cookie.Values.Add("age","30");
//控制cookie有效日期
cookie.Expires = DateTime.Now.AddHours(1);
//发送cookie
Response.AppendCookie(cookie);
//或者
Response.Cookies.Add(cookie);
//读取cookie
HttpCookie cookieRead = Request.Cookies["user"];
//删除cookie
cookie.Expires = DateTime.Now.AddHours(-1);
//跨域读取cookie
cookie.Domain = "wty.demo.com";
cookie.Domain = "support.demo.com";