CakePHP的会话超时非活动只 [英] CakePHP Session Timeout on Inactivity only

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

问题描述

所以,这个问题的关键就是如何从去验证一个闲置一段时间后只有一个会话。prevent的CakePHP

So the crux of this question is just how to prevent CakePHP from de-authenticating a session ONLY after a period of inactivity.

因此​​,如果用户不执行任何操作,然后我预计的CakePHP到30分钟后记录出来。但是,如果用户选择非活动的第28分钟访问一个页面,然后CakePHP的应该'重置'这是超时计数器。

So, if the user does nothing then I expect CakePHP to log them out after a period of 30 minutes. However, if the user chooses to visit a page on the 28th minute of inactivity, then CakePHP should 'reset' it's timeout counter.

这目​​前没有发生。无论活动,CakePHP的超时在我的核心配置在指定时间后(应用程序/配置/ core.php文件)。

This currently isn't happening. Regardless of activity, CakePHP times out after the specified time in my core configuration (app/Config/core.php).

下面是我的配置code:

Here's my config code:

Configure::write('Session', array(
    'defaults' => 'cake',
    'timeout' => '30'
));

任何想法?

推荐答案

运行到同样的问题后,我发现,这是由Session.cookieTimeout值造成的。虽然PHP会话仍然有效,对会话cookie的到期日期没有得到刷新。

After running into the same problem I've found that this was caused by the Session.cookieTimeout value. Although the php session was still valid, the expiration date on the session cookie does not get refreshed.

这是我现在的会话配置

Configure::write('Session', array(
        'defaults' => 'php',
        'timeout' => 30, // The session will timeout after 30 minutes of inactivity
        'cookieTimeout' => 1440, // The session cookie will live for at most 24 hours, this does not effect session timeouts
        'checkAgent' => false,
        'autoRegenerate' => true, // causes the session expiration time to reset on each page load
    ));

这篇关于CakePHP的会话超时非活动只的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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