Hi,
I've found an issue with formsauthentication and persistent cookie.
Scenario:
CS 2.0
ASP.NET 2.0
ASP.NET 2.0 built-in membership/roles/profile
This is a piece of my web.config:
<forms name=".CommunityServer"
protection="All" timeout="60" loginUrl="login.aspx" slidingExpiration="true"
/>
The problem:
1) In the login form, I select "Remember me", so I want a persistent authentication ticket (and cookie)
2) I'm logged on
3) I close the browser, open again, and I'm logged on (nothing strange... it's a persistent cookie)
4) I close the browser, and I wait for 60 minutes. After 60 minutes, I open the web site, and I'm not logged on! (this is STRANGE)
Due to this strange behavior, I inspected the code... and I can see that in "UserCookie.WriteCookie" you add 30 days to the cookie expiration.
The problem is that this is not sufficient in ASP.NET 2.0, because of the new behavior of FormsAuthentication, that will use the "timeout" value you set in web.config file also for persistent cookies.
Googling I've found this:
http://blogs.msdn.com/dansellers/archive/2006/02/15/532359.aspx
This change in ASP.NET 2.0 is not well documented. The only official document I've found is:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/PAGExplained0002.asp
this is an excerpt:
"timeout is used to specify a limited lifetime for the forms authentication session. The default value is 30 minutes. If a persistent forms authentication cookie is issued, the timeout attribute is also used to set the lifetime of the persistent cookie."
So, the result is that you add 30 days for the cookie expiration... but the ticket will expire after 60 minutes.
What do you think about this problem?
Did you find a solution?
Thanks,
Bye