当用户插入时,我有一个cookie:
HttpCookie cookie = new HttpCookie("Username");
cookie.Expires = DateTime.Now.AddDays(1.0);
cookie.Value = txtUsername.Text;
Response.Cookies.Add(cookie);
Run Code Online (Sandbox Code Playgroud)
当用户再次访问时,它会在登录页面中读出:
if (Response.Cookies["Username"] != null) txtUsername.Text = Response.Cookies["Username"].Value;
Run Code Online (Sandbox Code Playgroud)
但是当我登录,然后我直接注销后,cookie就会被删除.它既没有exp-date也没有保存值.
Whot我错了吗?
小智 6
if (Response.Cookies["Username"] != null) txtUsername.Text = Response.Cookies["Username"].Value
Run Code Online (Sandbox Code Playgroud)
应该
if (Request.Cookies["Username"] != null) txtUsername.Text = Request.Cookies["Username"].Value
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
231 次 |
| 最近记录: |