Пример #1
0
 public SessionInfo GetSession()
 {
     SessionInfo oSession = (SessionInfo)Session[AppConfig.AdminSession];
     if (oSession == null)
     {
         oSession = new SessionInfo();
         Session[AppConfig.AdminSession] = oSession;
     }
     return oSession;
 }
Пример #2
0
 public void LoginCheck(string username, string password)
 {
     SYS_AdminMod m_admin = SYS_AdminBll.GetInstance().CheckAdmin(username, password);
     if (m_admin.CustomerSysNo != AppConst.IntNull)//COOKIES验证成功
     {
         WebForAdmin.SessionInfo m_session = new SessionInfo();
         m_session.AdminEntity = m_admin;
         m_session.PrivilegeDt = SYS_AdminBll.GetInstance().GetAdminPrivilege(m_admin.SysNo);
         Session[AppConfig.AdminSession] = m_session;
         //记住我
         if (CheckBox1.Checked)
         {
             HttpCookie Cookie = CookiesHelper.GetCookie("upup1000Admin");
             if (Cookie == null || Cookie.Value == null || Cookie.Value == "")
             {
                 Cookie = new HttpCookie("upup1000Admin");
                 Cookie.Values.Add("uname", CommonTools.Encode(username));
                 Cookie.Values.Add("psd", CommonTools.Encode(password));
                 //设置Cookie过期时间
                 Cookie.Expires = DateTime.Now.AddYears(50);
                 CookiesHelper.AddCookie(Cookie);
             }
             else
             {
                 CookiesHelper.SetCookie("upup1000Admin", "uname", CommonTools.Encode(username), DateTime.Now.AddYears(50));
                 CookiesHelper.SetCookie("upup1000Admin", "psd", CommonTools.Encode(password), DateTime.Now.AddYears(50));
             }
         }
         LogManagement.getInstance().WriteTrace(m_session.AdminEntity, "Login", "IP:" + Request.UserHostAddress + "|AdminID:" + m_session.AdminEntity.Username);
         //跳转
         if (Request.QueryString["url"] != null && Request.QueryString["url"] != "")
         {
             Response.Redirect(Request.QueryString["url"]);
         }
         else
         {
             Response.Redirect("Welcome.aspx");
         }
     }
     else
     {
         this.ltrNotice.Text = "用户名或密码错误!";
         base.ClientScript.RegisterStartupScript(base.GetType(), "", "document.getElementById('" + divNotice.ClientID + "').style.display='';", true);
     }
 }