如果用户在yii2中的活动时间超过5分钟,我是否知道如何自动注销功能?
答案 0 :(得分:1)
答案 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'
],
],