在yii2中无效5分钟后自动注销

时间:2016-10-20 10:39:43

标签: yii2 yii2-advanced-app

如果用户在yii2中的活动时间超过5分钟,我是否知道如何自动注销功能?

3 个答案:

答案 0 :(得分:1)

尝试此配置:

'user' => [
        'enableAutoLogin' => false,
        'authTimeout' => 300,
    ],

authTimeout

答案 1 :(得分:0)

您的答案在于配置文件中“user”组件的配置。

您需要知道的一切都在本文档Yii2 User Component中,将authTimout属性设置为300(以秒为单位),并且您的用户应在5分钟不活动后注销。

答案 2 :(得分:0)

在您的组件配置中,您需要像这样在用户组件中添加配置

'components'=>[
        'user' => [
            'class'=>'yii\web\User',
            'identityClass' => 'common\models\User',
            'loginUrl'=>['sign-in/login'],
            'enableAutoLogin' => false,
            'authTimeout'=>300,  //Number of second to Automatic Logout if inactive
            //this config is optional
            'identityCookie' => [
                'name' => '_backendUser', // unique for backend
                'path'=>'@backend/web'  // correct path for the backend app.
            ],
            'as afterLogin' => 'common\behaviors\LoginTimestampBehavior'
        ],
    ],