public ActionResult LogOff() { Session[SessionManager.Instance.SessionKey] = null; SessionManager.Logout(); CookieHelp.SetCookie(SessionManager.Instance.UserInfoTicketKey, "", DateTime.Now.AddSeconds(5)); return(RedirectToAction("Index", "Home")); }
/// <summary> /// 填充用户登录信息 /// </summary> /// <param name="model">登录模型</param> /// <param name="info">登录用户信息</param> /// <returns>true 成功 false 失败</returns> public bool FillLoginInfo(UserLoginInfo info, LoginViewModel model = null) { try { //写入Session信息 Session[SessionManager.Instance.SessionKey] = info; if (model != null) { //写入用户信息票据,有效期为浏览器进程 AccountTicket usertick = new AccountTicket(); usertick.Password = model.Password; usertick.SessionId = Session.SessionID; usertick.UserAccount = model.LoginName; string strticket = usertick.UserAccount; CookieHelp.SetCookie(SessionManager.Instance.UserInfoTicketKey, strticket, DateTime.Now.AddDays(1)); } //if (model.IsAutoLogin) //{ // //下次自动登录,写入自动登录票据 // QM_LoginTicket loginticket = new QM_LoginTicket(); // loginticket.CreateTime = DateTime.Now; // loginticket.UserName = model.UserAccount; // loginticket.UserPassword = model.UserPassword; // string strlogin = SerializableHelp.SerializableAndEncrypt<QM_LoginTicket>(loginticket); // CookieHelp.SetCookie(SessionManager.Instance.UserAutoLoginTicketKey, strlogin, DateTime.MaxValue); //} } catch (Exception ex) { //LogHelper.WriteLog("登录信息填充失败", ex); return(false); } return(true); }