1
Cookie的用法也和ASP中差不多。比如我们建立一个名为aspcn,值为飞刀的cookie
2
3 HttpCookie cookie = new HttpCookie[ " aspcn " ];
4 cookie.Value = " 飞刀 " ;
5 Response.AppendCookie(cookie);
6
7 我们取出Cookie值也很简单
8
9 HttpCookie cookie = Request.Cookies[ " aspcn " ];
10 cookieValue = cookie.Value;
11
12 有时候我们想在一个Cookie中储存多个信息,那也没有问题。比如我们在名为aspcn的cookie下加多个信息
13
14 HttpCookie cookie = new HttpCookie( " aspcn " );
15 cookie.Values.Add( " webmaster " , " 飞刀 " );
16 cookie.Values.Add( " writer " , " beige " );
17 cookie.Values.Add( " LinkColor " , " blue " );
18 Response.AppendCookie(cookie);
19
20 取出信息也一样简单
21
22 HttpCookie cookie = Request.Cookies[ " aspcn " ];
23 value1 = cookie.Values[ " webmaster " ];
24 value2 = cookie.Values[ " writer " ];
2
3 HttpCookie cookie = new HttpCookie[ " aspcn " ];
4 cookie.Value = " 飞刀 " ;
5 Response.AppendCookie(cookie);
6
7 我们取出Cookie值也很简单
8
9 HttpCookie cookie = Request.Cookies[ " aspcn " ];
10 cookieValue = cookie.Value;
11
12 有时候我们想在一个Cookie中储存多个信息,那也没有问题。比如我们在名为aspcn的cookie下加多个信息
13
14 HttpCookie cookie = new HttpCookie( " aspcn " );
15 cookie.Values.Add( " webmaster " , " 飞刀 " );
16 cookie.Values.Add( " writer " , " beige " );
17 cookie.Values.Add( " LinkColor " , " blue " );
18 Response.AppendCookie(cookie);
19
20 取出信息也一样简单
21
22 HttpCookie cookie = Request.Cookies[ " aspcn " ];
23 value1 = cookie.Values[ " webmaster " ];
24 value2 = cookie.Values[ " writer " ];