0

I have a C# application that uses cookies to track user authentication (pretty standard stuff). On authentication, a cookie is created with a hash value relating to the database table containing user/authentication information.

In Chrome/Safari/Edge, this works perfectly: in IE11 the cookie is created (I can see it in Developer tools on the login confirmation page), but when clicking an internal link the user is kicked back out to the authentication page (by an ActionFilter, due to no cookie being present) and the cookie is no longer present when viewing the login form. It appears to work correctly when debugging from Visual Studio, and intermittently will even work on the live server when performing the exact same login process.

What could be causing this in IE11, but not Chrome/Edge? (Avoiding IE11 is, unfortunately, not an option). This occurs even with cookies set to Allow for both first and third party, with the site in the Trusted Sites list, and in the compatibility window

Edit: Added code (minus key and value)

Create:

HttpCookie cookie = new HttpCookie("AppSettings");
cookie.Values["key"] = value;
cookie.Expires = DateTime.Now.AddDays(TMSCookie.CookieValidityDays); // 365
Response.Cookies.Add(cookie);

Retrieve

// In MVC Filter
HttpCookie cookie = filterContext.HttpContext.Request.Cookies.Get("AppSettings");
// Otherwise
HttpCookie cookie = Request.Cookies.Get("AppSettings");
String value = cookie.Values["key"];
Jon Story
  • 2,881
  • 2
  • 25
  • 41

0 Answers0