0

Following is the code for setting the cookie:

FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, "AuthenticationToken", DateTime.Now,
                DateTime.Now.AddSeconds(60), false, "");
string encryptedText = FormsAuthentication.Encrypt(ticket);
Response.Cookies.Add(new HttpCookie("AuthenticationToken", encryptedText));

Following is the code for reading the cookie:

string cookie= Request.Cookies["VPAuthenticationToken"].Value;

this code works fine in Firefox and chrome but does not work in IE 11. This works in IE, Chrome and Firefox on local and Dev. In IE 11, while reading the cookie it is throw null reference exception. I have looked at the Request cookies in Chrome and they are being set to a value whereas the request cookie is not being set in IE 11 I have already tried clearing cookies and setting the security to lowest. Also, this code is triggered from a cross domain call, could that be causing this issue?

5
  • also try to add the 'domain' on the cookies
    – Aristos
    Commented Feb 18, 2020 at 12:24
  • Domain is already present in the request cookies
    – Prashant
    Commented Feb 18, 2020 at 12:48
  • @Aristos, took me sometime to understand that this could be related to the domain.
    – Prashant
    Commented Feb 18, 2020 at 15:22
  • Check this answer : stackoverflow.com/questions/12506532/…
    – Aristos
    Commented Feb 18, 2020 at 15:26
  • It seems that IE 11 does not like a domain value in the cookie. You could try to leave it empty. You could refer to this thread and this article for more information. Besides, you could try to use HttpContext.Current.Response.Cookies.Add(myCookie);.
    – Yu Zhou
    Commented Feb 20, 2020 at 5:29

0

Browse other questions tagged or ask your own question.