针对不同用户的不同会话超时 [英] Different session time out for different users

查看:134
本文介绍了针对不同用户的不同会话超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能有不同的用户不同的会话超时?我需要有管理员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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆