成功登录后,我想保存一个包含用户名的cookie.
cookie正确保存并正确加载用户名但丢失会话!
retreive用户名的代码是:
if (Request.Cookies["userName"] != null)
{
txtEmail.Text = Request.Cookies["username"].Value;
chkRemember.Checked = true;
}
Run Code Online (Sandbox Code Playgroud)
保存用户名的代码是:
HttpCookie aCookie = new HttpCookie("username");
aCookie.Value = txtEmail.Text;
aCookie.Expires = DateTime.Now.AddYears(5);
Response.Cookies.Add(aCookie);
Run Code Online (Sandbox Code Playgroud)
非常感谢任何帮助,谢谢