写入:
HttpCookie cookie=new HttpCookie(“user”);
cookie.Values.Add(“Id”,id);
cookie.Values.Add(“Name”,name);
//设置一天过期
cookie.Expires=DateTime.Now.AddDays(1);
//删除
cookie.Expires=DateTime.Now.AddDays(-1);
读取:
HttpCookie cookie=Request.Cookies[“user”];
if(cookie!=null){
string ids=cookie.Values[“Id”].Tostring();
string names=cookie.Values[“name”].Tostring();
}
转载于:https://www.cnblogs.com/jiakai/p/5548514.html