Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

When the specific user logs in, set the Session.Timeout property[^] to whatever you want it to be:
C#
Session.Timeout = 1; // Minutes
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900