Tom Troughton
Tom Troughton

Reputation: 4325

Firefox isn't allowing me to set a persistent cookie with FormsAuthentication

I have code which validates a login form (with an option to "remember me") and, if valid, authenticate the user. I then set the forms auth cookie and redirect.

The auth cookie is set as follows, with the persistent argument being true if the user has selected "remember me".

FormsAuthentication.SetAuthCookie(response.UserObject.UserName, persistent);
Response.Redirect(url);

We've tested this in various browsers and generally all is well. However, in Firefox the .ASPXFORMSAUTH cookie is always a session cookie which expires when the browser is closed, even when the persistent argument above is true.

The version of Firefox I'm testing with is 55.0.3 (32 bit). Is this a known bug? Or is there some other reason Firefox might not be letting me set a persistent cookie? Could it be that it no longer accepts persistent cookies as part of a 302 redirect response?

Upvotes: 2

Views: 647

Answers (1)

Tom Troughton
Tom Troughton

Reputation: 4325

Thanks to a pointer from @gabriel-luci I found the solution. In the Firefox preferences (about:preferences#privacy) my browser had been set to use custom settings for History and was configured to keep cookies only until Firefox was closed. I don't remember changing this myself, but a check with colleagues suggests that the default is to keep cookies until they expire. So if you're getting the same issue, start with Firefox prefs.

Upvotes: 4

Related Questions