Asp.Net Core MVC 记住密码
https://www.cnblogs.com/Hmd528/p/10695156.html
if (lm.RememberMe)
{
HttpCookie hc = new HttpCookie("UserInfo");
//在cookie对象中保存用户名和密码
hc["UserName"] = lm.UserName;
hc["UserPwd"] = lm.Password;
//设置过期时间
hc.Expires = DateTime.Now.AddDays(2);
//保存到客户端
Response.Cookies.Add(hc);
}
else
{
HttpCookie hc = new HttpCookie("UserInfo");
//判断hc是否空值
if (hc != null)
{
//设置过期时间
hc.Expires = DateTime.Now.AddDays(-1);
//保存到客户端
Response.Cookies.Add(hc);
}
}