1.cookie 將信息保存在客戶端。session和application 保存在服務(wù)器端
2.cookie有兩類:會話cookie(暫時(shí)性,保存在游覽其中)持久性cookie保存在客戶端
會話cookie創(chuàng)建:Httpcookie cook = new Httpcookie(名字,值);
取值:Response.Write(Response.Cookies[名字].Value);
持久性cookie創(chuàng)建:Httpcookie cook = new Httpcookie(名字,值);
缺點(diǎn):保存在客戶端,不安全
//創(chuàng)建cookie
HttpCookie cook = new HttpCookie("Username");
cook.value = "張三";
Response.Cookies.Add(cook);
// 提取cookie
string c = Request.Cookies["Username"].value;
Response.Write(c);