求问cookie问题
Response.Cookies["ID"].Expires = DateTime.Now.AddDays(14);
到期后 Request.Cookies["ID"] != null
Response.Cookies["ID"].Expires = DateTime.Now.AddMinutes(4);
到期后 Request.Cookies["ID"] == null
这是为什么?
------解决方案--------------------
不推荐使用
Response.Cookies["ID"].Expires这种方法,
设置Cookie应该
HttpCookie h = new HttpCookie("ID","value");
h.Expires = DateTime.Now.AddDays(14);
Response.Cookies.Add(h);
读取应该是
Request.Cookies["ID"]
Request.Cookies 和 Response.Cookies 的区别
http://dotnet.aspx.cc/file/Difference-Response-Cookies-Request-Cookies.aspx