//记住的用户名
HttpCookie GetCookieUsersName = Request.Cookies["Login_UsersName"];
if (GetCookieUsersName != null && !string.IsNullOrEmpty(GetCookieUsersName.Value))
{
userName.Value = GetCookieUsersName.Value;
}
//记住用户名
HttpCookie CookieUsersName = new HttpCookie("Login_UsersName", userName.Value.Trim());
Response.Cookies.Add(CookieUsersName);
//十天免登录
//Std.Page.StdUserControl.setSaveTime = 10;
简单SESSION用法
{
HttpCookie GetCookieUsersName = Request.Cookies["Login_UsersName"];
if (GetCookieUsersName != null && !string.IsNullOrEmpty(GetCookieUsersName.Value))
{
userName.Value = GetCookieUsersName.Value;
}
//记住用户名
HttpCookie CookieUsersName = new HttpCookie("Login_UsersName", userName.Value.Trim());
Response.Cookies.Add(CookieUsersName);
//十天免登录
//Std.Page.StdUserControl.setSaveTime = 10;
简单SESSION用法
{
session中存放一些值,比如
Session["UserName"]="admin"
Session["Pass"]="admin"
然后在另外一个页面中,你可以使用它:
If(Session["UserName"]="admin")
..........
}
#region 记录登录的Session
SessionUser sessionUser = new SessionUser();
sessionUser.UserId = user.UserId;
sessionUser.Account = user.Account;
sessionUser.UserName = user.RealName;
sessionUser.Gender = user.Gender;
sessionUser.Password = user.Password;
sessionUser.Code = user.Code;
sessionUser.Secretkey = user.Secretkey;
sessionUser.DepartmentId = user.DepartmentId;
sessionUser.LoginDate = DateTime.Now.ToString();
RequestSession.AddSessionUser(sessionUser);
#endregion
//取出session
SessionUser sessionUser = new SessionUser();
sessionUser = RequestSession.GetSessionUser();
#region 记录登录的Session
SessionUser sessionUser = new SessionUser();
sessionUser.UserId = user.UserId;
sessionUser.Account = user.Account;
sessionUser.UserName = user.RealName;
sessionUser.Gender = user.Gender;
sessionUser.Password = user.Password;
sessionUser.Code = user.Code;
sessionUser.Secretkey = user.Secretkey;
sessionUser.DepartmentId = user.DepartmentId;
sessionUser.LoginDate = DateTime.Now.ToString();
RequestSession.AddSessionUser(sessionUser);
#endregion
//取出session
SessionUser sessionUser = new SessionUser();
sessionUser = RequestSession.GetSessionUser();
Session.Abandon();//清除全部Session
//清除某个Session
Session["UserName"] = null;
Session.Remove("UserName");
vb.net版本
'''清除全部
Session.Abandon()
Session.Clear()
'''清除某个Session
Session("UserInfo") = Nothing
Session.Remove("UserInfo")