protected void btnLogin_Click(object sender, ImageClickEventArgs e) { string userName = this.txtUserName.Text.Trim(); string password = this.txtPassWord.Text.Trim(); string code = this.txtCode.Text.Trim().ToLower(); if (userName == "" || password == "" || code == "") { this.ClientScript.RegisterClientScriptBlock(GetType(), "01", "<script>alertmsg(\"�û��������롢��֤�������д�� \")</script>"); return; } if (Core.Utils.GetSession("VNum") == null || Core.Utils.GetSession("VNum") == "") { this.ClientScript.RegisterClientScriptBlock(GetType(), "01", "<script>alertmsg(\"��֤����ڣ� \")</script>"); return; } if (txtCode.Text.Trim().ToLower() != Core.Utils.GetSession("VNum").ToLower()) { this.ClientScript.RegisterClientScriptBlock(GetType(), "01", "<script>alertmsg(\"��֤����� \")</script>"); return; } XYECOM.Business.Admin adminBLL = new XYECOM.Business.Admin(); int err = adminBLL.isMyUser(txtUserName.Text.Trim(), XYECOM.Core.SecurityUtil.MD5(txtPassWord.Text.Trim(), XYECOM.Configuration.Security.Instance.Md5value)); if (err > 0) { XYECOM.Model.AdminInfo adminInfo = adminBLL.GetItem(this.txtUserName.Text.Trim()); Session.Add("UM_ID", adminInfo.UM_ID); Session.Add("A_Name", userName); Session.Add("AdminName", userName); ////��cookie ���ܴ洢 XYECOM.Core.Utils.WriteCookie("AdminId", XYECOM.Core.SecurityUtil.AESEncrypt(adminInfo.UM_ID.ToString(), XYECOM.Configuration.Security.Instance.AESKey), ""); XYECOM.Core.Utils.WriteCookie("AdminName", XYECOM.Core.SecurityUtil.AESEncrypt(userName, XYECOM.Configuration.Security.Instance.AESKey), ""); XYECOM.Core.Utils.WriteCookie("AdminPwd", adminInfo.UM_Pwd, ""); XYECOM.Core.Utils.WriteCookie("AdminExpires", XYECOM.Core.SecurityUtil.AESEncrypt(DateTime.Now.AddMinutes(30).ToLongTimeString(), XYECOM.Configuration.Security.Instance.AESKey), ""); // ��½��־ XYECOM.Model.LogInfo el = new XYECOM.Model.LogInfo(); XYECOM.Business.Log l = new XYECOM.Business.Log(); el.L_Title = "��½��־����"; el.L_Content = "����Ա��½��Ϣ"; el.L_MF = "��½��־����"; el.UM_ID = adminInfo.UM_ID; l.Insert(el); Response.Redirect("default.htm"); } else { this.ClientScript.RegisterClientScriptBlock(GetType(), "01", "<script>alertmsg(\"�û�������������� \")</script>"); } }
/// <summary> /// ����̨�û�Session״̬ /// </summary> /// <returns>Session�Ƿ����</returns> public static bool CheckManageSessionState() { string adminDir = XYECOM.Configuration.WebInfo.Instance.AdminFolder; //��Session״̬��ʧʱͨ��Cookie������֤ if (Core.Utils.GetSession("A_Name") == "" || Core.Utils.GetSession("UM_ID") == "") { if (Core.Utils.GetCookie("AdminId") == "" || Core.Utils.GetCookie("AdminName") == "" || Core.Utils.GetCookie("AdminExpires") == "" || Core.Utils.GetCookie("AdminPwd") == "") { return false; } //��ȡ�û�����ID string adminId = Core.Utils.GetCookie("AdminId"); string adminName = Core.Utils.GetCookie("AdminName"); string adminPwd = Core.Utils.GetCookie("AdminPwd"); string adminExpires = Core.Utils.GetCookie("AdminExpires"); //���� adminId = XYECOM.Core.SecurityUtil.AESDecrypt(adminId, XYECOM.Configuration.Security.Instance.AESKey); adminName = XYECOM.Core.SecurityUtil.AESDecrypt(adminName, XYECOM.Configuration.Security.Instance.AESKey); adminExpires = XYECOM.Core.SecurityUtil.AESDecrypt(adminExpires, XYECOM.Configuration.Security.Instance.AESKey); //�жϹ���ʱ�� DateTime time = Convert.ToDateTime(adminExpires); TimeSpan timeSpan = time - DateTime.Now; XYECOM.Configuration.WebInfo webInfo = XYECOM.Configuration.WebInfo.Instance; int span = timeSpan.Minutes; //����Ѿ����� if (span < 0) { Core.Utils.ClearCookie("AdminId", webInfo.CookieDomain); Core.Utils.ClearCookie("AdminName", webInfo.CookieDomain); Core.Utils.ClearCookie("AdminPwd", webInfo.CookieDomain); Core.Utils.ClearCookie("AdminExpires", webInfo.CookieDomain); return false; } //��ȡ�û���������������֤ int result = new XYECOM.Business.Admin().isMyUser(adminName, adminPwd); if (result <= 0) { Core.Utils.ClearCookie("AdminId", webInfo.CookieDomain); Core.Utils.ClearCookie("AdminName", webInfo.CookieDomain); Core.Utils.ClearCookie("AdminPwd", webInfo.CookieDomain); Core.Utils.ClearCookie("AdminExpires", webInfo.CookieDomain); return false; } //�������ù���ʱ�䣬����20���� Core.Utils.WriteCookie("AdminExpires", XYECOM.Core.SecurityUtil.AESEncrypt(DateTime.Now.AddMinutes(30).ToLongTimeString(), XYECOM.Configuration.Security.Instance.AESKey), webInfo.CookieDomain); //����Session Core.Utils.SetSession("A_Name", adminName); Core.Utils.SetSession("UM_ID", adminId); } return true; }