Firefox does not accept ASP.NET authentication cookies

1.3k Views Asked by At

I'm having this issue with Firefox browser when deploy our application to the QA environment. We have an ASP.NET 4 application with Form Authentication. In our application, we have 2 cookies: 1 for authentication ticket, another for other information. The issue is: everytime I login to the system using Firefox, I'm bounced back to the login page. When I use Fiddle to investigate the issue, I found out that for some reason Firefox doesn't "accept" our cookies: The 1st request to the Login page, our server returns the cookies just fine in the Headers:

Set-Cookie: .ASPXAUTH_Imp=...; expires=Thu, 07-Jun-2012 06:37:24 GMT; path=/
Set-Cookie: .ASPXAUTH=...; expires=Wed, 06-Jun-2012 09:57:24 GMT; path=/ 

However, in the next response, our cookies do not present in the request header. This issue does not happen in any other browsers (IE, Chrome, etc). In other browsers, the cookies are accepted and passed along in the next requests.

When I view the cookies stored in Firefox, I can see my website, but it has only the ASP.NET_sessionID cookie. There's no trace of the other 2 cookies. One more interesting point is this issue only happens in QA environment ( which has the LAN IP 10.16.x.x. I tried to use the machine name the the issue persists). When I debug in Visual Studio using localhost, it works perfectly fine. This is my code for sending Cookie to client:

' ASP.NET authentication cookie '
Dim cookieExpiration As DateTime = DateTime.Now.AddMinutes(Constants.WebSettingsConst.TimeOut)
Dim authenticationTicket = New FormsAuthenticationTicket(2, CurrentContext.UserContextID(), DateTime.Now, cookieExpiration, True, String.Empty, FormsAuthentication.FormsCookiePath)
Dim encryptedTicket As String = FormsAuthentication.Encrypt(authenticationTicket)
Dim authCookie = New HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
authCookie.Expires = authenticationTicket.Expiration
authCookie.Path = FormsAuthentication.FormsCookiePath
'HttpContext.Current.Response.Cookies.Remove(FormsAuthentication.FormsCookieName)'
HttpContext.Current.Response.Cookies.Add(authCookie)
1

There are 1 best solutions below

0
On

It sounds obvious, but have you checked the cookie settings in FireFox. If you go into privacy and pick use custom history you can specify not to accept cookies from third parties or only from specific sites.

I'm doing exactly the same as you and have no problems.

Dim authTicket As New FormsAuthenticationTicket(1, userIdentity, Date.Now, _     
     Date.Now.AddMinutes(15), False, userData)
Dim encTicket As String = FormsAuthentication.Encrypt(authTicket)
Dim faCookie As New HttpCookie(FormsAuthentication.FormsCookieName, encTicket)
Response.Cookies.Add(faCookie)