普通类中:
HttpCookie cookie = new HttpCookie(CookieKeyCometUserName); cookie.Name = CookieKeyCometUserName; cookie.Value = userName; cookie.Expires = SystemTime.Now().AddDays(1); // 不加这句,就读不到,不知何故? HttpContext.Current.Response.Cookies.Add(cookie);
Hub方法中:
HttpCookie cookie = HttpContext.Current.Request.Cookies[CookieKeyCometUserName]; if (cookie != null) { return cookie.Value.DESDecrypt(); } return "";