forms authentication timeout

  • Thread starter Thread starter Andrew Robinson
  • Start date Start date
A

Andrew Robinson

Is there any way to dynamically set the timeout while using forms based
authentication? I want to change this value depending on the type of user
that logs into my system. I understand that this value lives in the config
file but can I change it in code?

Thanks,

-Andy
 
Yes the value lives in web.config but it is used when giving the user a
FormsAuthenticationTicket. Try creating a new ticket with the desired
expiration time for that user.
Peter
 
Thanks for Peter's input.

Hi Andy,

Though there does exist the "timeout" setting in the web.config for forms
authentication ticket, however, this is an global level setting for the
entire application which is not recommended to change frequently(it is load
into memory at appliation's startup time). Also, if you programmtically
change this value in web.config (directly through file IO api or the
WebConfigurationManager class), the ASP.NET application will restart
whenever it detect web.config file has been changed. So this is not
recommended.

As Peter has mentioned, the Forms Authentication Ticket is actually
persisted in a cookie (by default if you do not use cookieless), therefore,
the timeout value is also depend on that cookie's timeout. If you want to
control different timeout for different user, you can consider do the Forms
Authentication ticket & cookie generation your self in code. Thus, you can
set the timeout value of the cookie manually, here is a kb article
demonstrate this:

#How To Implement Forms-Based Authentication in Your ASP.NET Application by
Using C# .NET
http://support.microsoft.com/kb/301240/en-us

In addition, here is another good kb article explaining the forms
authentication's ticket and cookie:

#Understanding the Forms Authentication Ticket and Cookie
http://support.microsoft.com/kb/910443/en-us

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hello Andy,

Have you got any further progress or idea on this issue? Since we're still
monitoring this thread, please feel free to post here if there is anything
we can help.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top