自动登录

一:自动登录功能的实现

在登录页面有一个几天内自动登录的复选框。在用户勾选这个自动登录的复选框,点击登录。服务器去判断有没有这个复选框的值从而判断。

ps.1.服务器只能接收到已选的复选框,其它没有选的复选框不会提交到服务器。

 if (!string.IsNullOrEmpty(Request["autoLogin"]))
 {
      //创建cookie 
         Response.Cookies["userName"].Value = userName;
         Response.Cookies["userPassword"].Value = userPassword;
         Response.Cookies["userName"].Expires = DateTime.Now.AddDays(7);
         Response.Cookies["userPassword"].Expires = DateTime.Now.AddDays(7);
 }
原文地址:https://www.cnblogs.com/MzwCat/p/8486280.html