asp.net 添加删除cookie

asp.net 删除cookie

HttpCookie cookie1 = Request.Cookies["PPUser"];
cookie1.Expires = DateTime.Today.AddDays(-10);
cookie1.Domain = "huo7.com";
Response.Cookies.Add(cookie1);

asp.net 添加cookie

   HttpCookie cookie = new HttpCookie("PPUser");
   cookie.Values.Add("UserName",HttpUtility.UrlEncode(userName));
   cookie.Values.Add("Pwd",HttpUtility.UrlEncode(pwd));
   cookie.Expires = DateTime.Now.AddMinutes(expires);
   cookie.Path = "/";
   cookie.Domain = "huo7.com";
   Response.AppendCookie(cookie);

*  cookie.Domain = "huo7.com"; 可以做到网站的二级域名和一级域名公用cookie

你可能感兴趣的:(asp.net)