读写cookie
写cookie
HttpCookie hc = new HttpCookie("username", "xxxx");
hc.Expires = DateTime.Now.AddDays(2);
context.Response.Cookies.Add(hc);
context.Response.Write("写入cookie成功");
context.Response.Write("<a href='readcookie.ashx'>读cookie</a>");
读cookie
HttpCookie hc = context.Request.Cookies["username"];
if(hc!=null)
{
context.Response.Write("欢迎你" + hc.Value);
}
else
{
context.Response.Write("cookie为空");
}