Is it possible to have different session time outs for different users? I need to have 180 mins session for admin and 20 min for non-admin users.
Currently it is single session timeout for all the users. we are using a web.config key
Any help would be appriciated.
Setting Session.Timeout
property by code will set the timeout on a per user basis.
You can manually set Session.Timeout = 20;
or Session.Timeout = 180;
based on the user type when they log in.
This code should work for you:
protected void SetSessionTime(string userType)
{
if (UserType == "admin")
{
Session.Timeout = 180;
}
else
{
Session.Timeout = 20;
}
}
You can call SetSessionTime()
after user successfully logs in.