asp.net中用cookie记住密码上次不用登陆

------最佳解决方案--------------------
写入Cookie
Response.Cookies["UserName"].Value = "用户名";
Response.Cookies["CustomerID"].Expires = DateTime.Today.AddDays(30);

读取Cookie
if (Response.Cookies["UserName"].Value != null)

     //用户曾登录
     string username = Response.Cookies["UserName"].Value;    
}
else
{
     //新用户须进入登录界面
}
------其他解决方案--------------------


写入Cookie
//第一次登录的时候,点击登录按钮事件下写
Response.Cookies["UserName"].Value = "用户名"; 
Response.Cookies["CustomerID"].Expires = DateTime.Today.AddDays(30);  //设置过期时间,
//跳转到目标页面
Response.redirect("目标页面");

//在你的目标页的Load事件下写
if (Response.Cookies["UserName"].Value != null)
{
    //用户曾登录
    string username = Response.Cookies["UserName"].Value;   //读取Cookie
}
else
{
    //返回登录登录界面
Response.redirct("登录界面Url");
}

风雪七月花溅墨
原文地址:https://www.cnblogs.com/bobo41/p/3480655.html