使用COOKIE的问题

来源:百度知道 编辑:UC知道 时间:2024/05/03 22:50:54
怎么样进行COOKIE的存贮和读取 最好有例子

存储:
HttpCookie http = new HttpCookie("Code1");
//实例化一个cookie对象
http.Expires = Convert.ToDateTime("2009-1-1");
//设置过期时间
http.Value = "123321";
//设置值
Response.Cookies.Add(http);
//加入到客户端cookies集合

读取:
Response.Write(Request.Cookies["Code1"].Value.ToString());