cookie中存储一个信息
比如我们建立一个名为aspxcn,值为张三的cookie
HttpCookie myCookie = new HttpCookie("aspxcn");
myCookie.Value = "张三";
//默认是关掉浏览器cookie就过期,这个可以设置过期时间
myCookie.Expires = DateTime.Now.AddSeconds(50);
Response.AppendCookie(myCookie);
取出这个cookie的方法
HttpCookie mycook = Request.Cookies["aspxcn"];
this.Label1.Text = mycook.Value;
在一个Cookie中储存多个信息比如我们在名为aspxcn的cookie下加多个信息
HttpCookie myCookie = new HttpCookie("aspxcn");
myCookie.Values.Add("color", "blue");
myCookie.Values.Add("music", "love");
Response.AppendCookie(myCookie);
取出信息
HttpCookie mycookie = Request.Cookies["aspxcn"];
string values1 = mycookie["color"];
string values2 = mycookie["music"];
比如我们建立一个名为aspxcn,值为张三的cookie
HttpCookie myCookie = new HttpCookie("aspxcn");
myCookie.Value = "张三";
//默认是关掉浏览器cookie就过期,这个可以设置过期时间
myCookie.Expires = DateTime.Now.AddSeconds(50);
Response.AppendCookie(myCookie);
取出这个cookie的方法
HttpCookie mycook = Request.Cookies["aspxcn"];
this.Label1.Text = mycook.Value;
在一个Cookie中储存多个信息比如我们在名为aspxcn的cookie下加多个信息
HttpCookie myCookie = new HttpCookie("aspxcn");
myCookie.Values.Add("color", "blue");
myCookie.Values.Add("music", "love");
Response.AppendCookie(myCookie);
取出信息
HttpCookie mycookie = Request.Cookies["aspxcn"];
string values1 = mycookie["color"];
string values2 = mycookie["music"];