Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forms Authentication Cookie Expiration

I have an ASP.NET web application that uses Forms Authentication. In the web.config, the forms authentication timeout value is set to "20" (which I understand to be 20 minutes).

We're seeing an issue where you'll be interacting with the site..(i.e. clicking on linkbuttons, performing postbacks, etc.) and randomly get sent back to the Login page to authenticate.

It seems like the timeout is being obeyed, but activity is not restarting the counter.

Any ideas where to look or how to debug this?

like image 766
ctorx Avatar asked Mar 25 '26 15:03

ctorx


2 Answers

check slidingExpiration in web.config and make sure it's set to true

 <authentication mode="Forms">
   <forms loginUrl="~/Account/Login" timeout="2880" protection="All" slidingExpiration="true">      
   </forms>
 </authentication>

also is this load balanced web site? make sure session information is out of process, or use sticky session.

like image 192
RocketMan Avatar answered Mar 27 '26 03:03

RocketMan


Setting the timeout attribute on the <forms /> tag is also neccessary as described in this blog post about forms authentication.

like image 45
faester Avatar answered Mar 27 '26 05:03

faester



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!