Cookie记住账号
给大家分享的功能是Cookie记住账号
效果是记住账号后每次都可以直接登录不用再次输入账号密码(在不清除网页缓存的情况下)
效果图:
MVC代码:
//登陆页面
public ActionResult Login()
{
string Account = "";
string Password = "";
bool isRember = false;
HttpCookie cookie = System.Web.HttpContext.Current.Request.Cookies["operator"]
if (cookie != null)
{
if (cookie["Account"] != null)
{
Account=System.Web.HttpContext.Current.Server.UrlDecode(cookie["Account"]);
}
if (cookie["Password"] != null)
{
Password=System.Web.HttpContext.Current.Server.UrlDecode(cookie["Password"]);
}
isRember = true;
}
ViewBag.Account = Account;
ViewBag.Password = Password;
ViewBag.isRember =