针对不同用户的不同会话超时 [英] Different session time out for different users
问题描述
是否有可能有不同的用户不同的会话超时?我需要有管理员180分钟会话,20分钟的非管理员用户。
目前,它是所有用户的单个会话超时。我们使用一个web.config键
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
任何帮助将appriciated。
Any help would be appriciated.
推荐答案
设置查看Session.Timeout
通过代码属性将设置超时基于每个用户的基础。
Setting Session.Timeout
property by code will set the timeout on a per user basis.
您可以手动设置查看Session.Timeout = 20;
或查看Session.Timeout = 180;
根据登录时的用户类型
You can manually set Session.Timeout = 20;
or Session.Timeout = 180;
based on the user type when they log in.
这代码应该为你工作:
protected void SetSessionTime(string userType)
{
if (UserType == "admin")
{
Session.Timeout = 180;
}
else
{
Session.Timeout = 20;
}
}
您可以致电 SetSessionTime( )
后,用户成功登录
You can call SetSessionTime()
after user successfully logs in.
这篇关于针对不同用户的不同会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!