如何增加cakephp Auth组件会话过期时间 [英] How to increase cakephp Auth component session expire time

查看:80
本文介绍了如何增加cakephp Auth组件会话过期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using Auth component to check user is logged in.

这是我AppController的初始化函数

Here is my AppController's initialize function

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'
        ]
    ]);
}

工作正常。但是如果我在几分钟内保持不活动状态(例如3- 5分钟),然后转到单击发送给我登录页面的链接。会话时间似乎已过期。

Its working fine.But if I stay inactive for few minutes(like 3-5min) and go(click) to a link it sends me login page.It seems session time expired.

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

How or Where I can increase this time.

推荐答案

Auth组件共享会话类

Auth component shares Session class

对于Cakephp3

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

At config/app.php we can set the timeout.

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

对于Cakephp2

在您的Config / core.php中

in your Config/core.php

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

这篇关于如何增加cakephp Auth组件会话过期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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