如何增加cakephp Auth组件会话过期时间

How to increase cakephp Auth component session expire time

我正在使用 Auth 组件来检查用户是否已登录。

这是我的 AppController 的初始化函数

public function initialize()
{
    parent::initialize();
    $this->loadComponent('Flash');
    $this->loadComponent('Auth', [
        'authenticate' => [
            'Form' => [
                'fields' => [
                    'username' => 'username',
                    'password' => 'password'
                ],
                'passwordHasher' => [
                    'className' => 'Md5',//My own password hasher
                ]
            ]
        ],
        'loginAction' => [
            'controller' => 'Dashboard',
            'action' => 'login'
        ]
    ]);
}

它的工作 fine.But 如果我保持不活动状态几分钟(比如 3-5 分钟)然后转到(单击)link 它会向我发送登录信息 page.It 似乎会话时间已过期.

我可以如何或在哪里增加这次时间。

Auth 组件共享 Session class

为了蛋糕php3

在config/app.php我们可以设置超时。

'Session' => [
    'defaults' => 'php',        
    'timeout'=>24*60//in minutes
],

为了蛋糕php2

在你的 Config/core.php

Configure::write('Session', array(
    'defaults' => 'php',
    'timeout' => 31556926 //increase time in seconds
));

Auth 组件共享会话 class。对于 CakePHP 3,您可以将会话超时设置为 config/app.php,如下所示:

'Session' => [
        'defaults' => 'php',
        'timeout'  => 1440, /*24 hours*/
    ],