------最佳解决方案--------------------
写入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");
}spa