【发布时间】:2011-01-07 04:57:03
【问题描述】:
我的 Web 应用程序的主页有一个 RememberMe 复选框。如果用户检查它,我会将电子邮件 ID 和密码存储在 cookie 中。这是我的代码:
if (this.ChkRememberme != null && this.ChkRememberme.Checked == true)
{
HttpCookie cookie = new HttpCookie(TxtUserName.Text, TxtPassword.Text);
cookie.Expires.AddYears(1);
Response.Cookies.Add(cookie);
}
我想知道的是:
- 将密码存储在 cookie 中是否安全?
- 做同样事情的正确方法是什么?
- 设置 Cookie 时间的最佳做法是什么?
【问题讨论】:
-
让 FormsAuthentication 解决这个问题! FormsAuthentication.SetAuthCookie(username, true);
标签: c# asp.net asp.net-mvc passwords remember-me