后台添加
HttpCookie newCookie = new HttpCookie("User");
newCookie.Values.Add("Name", olduser.UserNum);
newCookie.Expires = DateTime.Now.AddDays(30);
Response.AppendCookie(newCookie);
后台删除
HttpCookie newCookie = new HttpCookie("User");
newCookie.Values.Add("Name", "");
newCookie.Expires = DateTime.Now.AddDays(-1);
Response.AppendCookie(newCookie);
前台读取
@if (@Request.Cookies["User"] == null)
@Request.Cookies["User"].Values["Name"]
评论区