/// <summary> /// 用当前用户的实体模型进行登录 /// </summary> /// <param name="user"></param> /// <returns></returns> public static bool Login(DBHelper.Model.JCUser user) { if (user == null) { return(false); } CurUserDetailInfo info = new CurUserDetailInfo(); info.UserID = user.UserID; info.UserName = user.UserName; info.PassWord = user.PassWord; info.NickName = user.NickName; info.TrueName = user.TrueName; info.Email = user.Email; info.Phone = user.Phone; info.QQ = user.QQ; info.CreateTime = user.CreateTime; info.LastLoginTime = user.LastLoginTime; info.Birthday = user.Birthday; System.Web.HttpContext.Current.Session["CurUserDetailInfo"] = info; return(true); }
/// <summary> /// 记住登录状态 /// </summary> /// <param name="isRemember"></param> public static void RememberLoginStatusByCookie(bool isRemember) { HttpCookie cook = new HttpCookie("userInfo"); CurUserDetailInfo user = ((CurUserDetailInfo)System.Web.HttpContext.Current.Session["CurUserDetailInfo"]); var obj = new { UserName = user.UserName, PassWord = user.PassWord }; string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(obj); string desStr = Common.Helper.Common.EnDesCode(jsonStr); cook.Value = desStr; if (isRemember) { cook.Expires = DateTime.Now.AddDays(7); } else { ; } HttpContext.Current.Response.Cookies.Add(cook); }
/// <summary> /// 用当前用户的实体模型进行登录 /// </summary> /// <param name="user"></param> /// <returns></returns> public static bool Login(DBHelper.Model.JCUser user) { if (user == null) return false; CurUserDetailInfo info = new CurUserDetailInfo(); info.UserID = user.UserID; info.UserName = user.UserName; info.PassWord = user.PassWord; info.NickName = user.NickName; info.TrueName = user.TrueName; info.Email = user.Email; info.Phone = user.Phone; info.QQ = user.QQ; info.CreateTime = user.CreateTime; info.LastLoginTime = user.LastLoginTime; info.Birthday = user.Birthday; System.Web.HttpContext.Current.Session["CurUserDetailInfo"] = info; return true; }