想请教下你是怎么解决这个问题,我是mvc3+表单认证 但有些客户会出现登录密码和帐号都对,但是系统无法获取cookie,IsAuthenticated 一直为False 。一直解决不了这个问题,还请多多指教,附上登录验证代码。
HttpCookie authCookie = FormsAuthentication.GetAuthCookie(username, true); FormsAuthenticationTicket orgticket = FormsAuthentication.Decrypt(authCookie.Value); DateTime outtime = autologin ? DateTime.Now.AddDays(7) : DateTime.Now.AddHours(8); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(orgticket.Version, orgticket.Name, DateTime.Now, outtime, true, companyId.ToString() + "|" + companyname + "|1|" + item.lastlogintime + "|" + userType); string encTicket = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket) { HttpOnly = true, Path = ticket.CookiePath, Expires = ticket.IsPersistent ? ticket.Expiration : DateTime.MinValue, Domain = FormsAuthentication.CookieDomain, }; HttpContext.Response.Cookies.Add(cookie);