.net读取cookie中的值17
发布网友
发布时间:2023-11-19 05:34
我来回答
共2个回答
热心网友
时间:2024-12-01 01:41
你好:
写入方法:
HttpCookie cookie = new HttpCookie("id");
cookie.Value=cookieValue;
cookie.Expires = DateTime.Now+new TimeSpan(0,1,0,0));
Response.Cookies.Add(cookie);
读取方法:
HttpCookie cookie = Request.Cookies["id"];
if(null == cookie)
{
Label1.Text = "";
}
else
{
Label1.Text = cookie.Value;
}
热心网友
时间:2024-12-01 01:41
if (Request.Cookies["id"]!=null)
Label1.Text=Request.Cookies["id"].Value;