写入:HttpCookiecookienewHttpCookie(“user”);cookie.Values.Add(Id,id);cookie.Values.Add(Nam 写入: HttpCOOKIE COOKIE=new HttpCOOKIE(“user”); COOKIE.Values.Add("Id",id); COOKIE.Values.Add("Name",name); //设置一天过期 COOKIE
写入:
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();
}