asp.net Cookie用法举例
本文导语: 代码如下: 设置cookie: HttpCookie cookie = new HttpCookie["aspcn"]; cookie.Value = "飞刀"; Response.AppendCookie(cookie); 读取cookie: HttpCookie cookie = Request.Cookies["aspcn"]; cookieValue = cookie.Value; Cookie储存多个信息: HttpCookie cookie = new HttpCookie("aspcn"); c...
HttpCookie cookie = new HttpCookie["aspcn"];
cookie.Value = "飞刀";
Response.AppendCookie(cookie);
读取cookie:
HttpCookie cookie = Request.Cookies["aspcn"];
cookieValue = cookie.Value;
Cookie储存多个信息:
HttpCookie cookie = new HttpCookie("aspcn");
cookie.Values.Add("webmaster","飞刀");
cookie.Values.Add("writer","beige");
cookie.Values.Add("LinkColor","blue");
Response.AppendCookie(cookie);
读取多个信息:
HttpCookie cookie = Request.Cookies["aspcn"];
value1 = cookies.Values["webmaster"];
value2 = cookies.Values["writer"];