/// <summary> /// 判断用户是否登陆 /// </summary> /// <returns></returns> public bool IsLogin(string cookieName) { var cookie = HttpContext.Current.Request.Cookies[cookieName]; if (cookie == null || String.IsNullOrWhiteSpace(cookie.Value)) { return(false); } #region 开始自已写cookie SymmetricEncrypt symenc = new SymmetricEncrypt(); var cookievalue = symenc.Decrypto(cookie.Value.Trim()); int uid; int validay; string uname; return(ValidityCookie(cookievalue, out uid, out validay, out uname)); #endregion }
/// <summary> /// 获得Cookie中保存的用户ID /// </summary> /// <returns></returns> public int GetUserID(string cookieName) { int userId = 0; int validityDays = 0; string uname = ""; var cookie = HttpContext.Current.Request.Cookies[cookieName]; if (cookie == null || String.IsNullOrWhiteSpace(cookie.Value)) { return(0); } #region 开始自已写cookie SymmetricEncrypt symenc = new SymmetricEncrypt(); var cookievalue = symenc.Decrypto(cookie.Value.Trim()); ValidityCookie(cookievalue, out userId, out validityDays, out uname); return(userId); #endregion }