Click here to Skip to main content
14,664,507 members
Rate this:
Please Sign up or sign in to vote.
See more:
How to increase or decrease session timeout from other then web config file. As in my schenario, I have to fix the session time out for all user but for some specific user i need to decrease manually from code.

What I have tried:

As in my schenario, I have to fix the session time out for all user but for some specific user i need to decrease manually from code.

I tried to set the session timeout using below code but not able to set.

FormsAuthenticationConfiguration obj = new FormsAuthenticationConfiguration();
obj.Timeout = TimeSpan.FromMinutes(1);
Posted
Updated 10-Aug-16 7:16am
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

When the specific user logs in, set the Session.Timeout property[^] to whatever you want it to be:
Session.Timeout = 1; // Minutes
   
Comments
riteshsingh_jsr 10-Aug-16 13:38pm
   
Thanks for reply however, I didn't able to find the Session.Timeout property for setting timeout.
Richard Deeming 10-Aug-16 13:49pm
   
It definitely exists - it wouldn't be in the MSDN documentation otherwise!

Try HttpContext.Current.Session.Timeout, in case you've got a naming conflict somewhere.
riteshsingh_jsr 11-Aug-16 13:47pm
   
tried the same but not worked as expected.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100