locked
.ASPXAUTH cookie value is null when the page gets loaded can't able to authenticate login RRS feed

  • Question

  • User-1149473135 posted

    hi

    in forms authentication i'm securing a cookie while logging in, but the form does n't get authenticated after entering the user credentials

    i'm securing the cookie at global.ascx.cs

    Please help me out on this

    Monday, August 4, 2014 3:13 AM

Answers

  • User-734925760 posted

    Hi,

    According to your description, your cookie is null, so you need to check that you have saved value to it, please refer to the code below to add value to cookie:

    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(userInfo.Username, false, 5);
               string encryptedTicket = FormsAuthentication.Encrypt(ticket);
               HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
               Response.Cookies.Add(authCookie);

    Hope it's useful for you.

    Best Regards,

    Michelle Ge

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 7, 2014 7:19 AM

All replies

  • User1779161005 posted

    There's much much info to go on here. I'd suggest debugging some more and posting a better description of what's happening (or not happening).

    Monday, August 4, 2014 9:35 AM
  • User-734925760 posted

    Hi,

    According to your description, your cookie is null, so you need to check that you have saved value to it, please refer to the code below to add value to cookie:

    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(userInfo.Username, false, 5);
               string encryptedTicket = FormsAuthentication.Encrypt(ticket);
               HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
               Response.Cookies.Add(authCookie);

    Hope it's useful for you.

    Best Regards,

    Michelle Ge

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 7, 2014 7:19 AM