.net读取cookie中的值
登陆页面:Response.Cookies["id"].Value=loginnum.Text;Response.Cookies["id"].Expires=DateTi...
登陆页面:Response.Cookies["id"].Value = loginnum.Text;
Response.Cookies["id"].Expires = DateTime.Now.AddDays(1);
转入的页面:
HttpCookie acookie = Request.Cookie("id");
Label1.Text = acookie.Value;
该怎么写呢 烦死了 搜索网上的方法都不行 不是不包含cookie的定义就是未引用到对象 帮帮忙 谢谢了
lipt1845你好 读取出来的还是空 怎么弄啊 展开
Response.Cookies["id"].Expires = DateTime.Now.AddDays(1);
转入的页面:
HttpCookie acookie = Request.Cookie("id");
Label1.Text = acookie.Value;
该怎么写呢 烦死了 搜索网上的方法都不行 不是不包含cookie的定义就是未引用到对象 帮帮忙 谢谢了
lipt1845你好 读取出来的还是空 怎么弄啊 展开
2个回答
展开全部
你好:
写入方法:
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;
}
写入方法:
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;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询