public baseCC() { CurrentUId = 0; CurrentUName = "admin"; CurrentTureName = "管理员"; //检查用户登录状态 try { HttpCookie co1 = System.Web.HttpContext.Current.Request.Cookies[CFun.GetAppStr("LoginCookieName")]; CurrentUId = Convert.ToInt32(co1["i"]); CurrentUName = co1["n"]; CurrentTureName = System.Web.HttpUtility.UrlDecode(co1["t"]); CurrentCheckCode = CFun.ParseInt(co1["c"]); CurrentRoleId = CFun.DESDecrypt(co1["r"], CFun.GetAppStr("DESKey")); CurrentRoleId = CurrentRoleId == "" ? "-1" : CurrentRoleId; CurrentRoleId = ("," + CurrentRoleId + ",").IndexOf(",0,") >= 0 ? "" : CurrentRoleId; CurrentUPost = Convert.ToInt32(CFun.DESDecrypt(co1["g"], CFun.GetAppStr("DESKey"))); //处理踢人下线 checkUserAvailable(); } catch { System.Web.HttpContext.Current.Response.Redirect(url); return; } if (CurrentUId <= 0) { System.Web.HttpContext.Current.Response.Redirect(url); return; } }
private void checkUserAvailable() { int times = 0; HttpCookie co = System.Web.HttpContext.Current.Request.Cookies["ccUserTimes"]; if (co != null) { times = CFun.ParseInt(co.Value); times++; if (times > 10) { times = 0; } } else { co = new HttpCookie("ccUserTimes"); } co.Value = times.ToString(); System.Web.HttpContext.Current.Response.Cookies.Add(co); if (times == 0) { if (ExecSql.GetDataSet("select ld from AdmUser where Ld=" + CurrentUId + " and CheckCode<>" + CurrentCheckCode).Tables[0].Rows.Count > 0) { new BllAdmUser().LogOut(); return; } } }
/// <summary> /// 返回当前登录的用户编号 /// </summary> /// <returns></returns> public static int GetCurrentUId() { try { HttpCookie co1 = System.Web.HttpContext.Current.Request.Cookies[CFun.GetAppStr("LoginCookieName")]; return(CFun.ParseInt(co1["i"])); } catch { return(0); } }