当前位置: 代码迷 >> ASP.NET >> 问一个cookies存与取值的有关问题
  详细解决方案

问一个cookies存与取值的有关问题

热度:6782   发布时间:2013-02-25 00:00:00.0
问一个cookies存与取值的问题
Response.Cookies["username"].Value = TextBox1.Text.Trim(); //保存 
 this.Label1.Text = "用户名:" + Response.Cookies["username"].Value;//获取  
请问下Cookies是不是这样用? 我是这样写的,但为什么我取值的时候取不到呢。。。

------解决方案--------------------------------------------------------
探讨
引用:
Response.Cookies["username"].Value = TextBox1.Text.Trim(); //保存
Response.Cookies["username"].Expires = DateTime.Now.AddDays(1);//过期时间
this.Label1.Text = "用户名:" + Request.Cookies["username"].Value;//获取

谢谢啦!!!
想请问下 HttpContext.Current.Response.Cookies 和 Response.Cookies 这样有什么区别啊
  相关解决方案