CakePHP会话不会自动更新 [英] CakePHP session not auto-renewing

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

问题描述

我在LAMP服务器上使用CakePHP v2,如果用户保持活动状态,我似乎遇到会话不会自动更新的问题。

I'm using CakePHP v2 on a LAMP server and I appear to have a problem with the session not automatically renewing itself if the user stays active.

在其他如果我将会话Cookie设置为3天,那么即使用户在整个时间内都处于活动状态,用户在3天后仍会退出。

In other words, if I set the session cookie to 3 days then the user gets logged out after 3 days even if they've been active the whole time.

虽然这可能是正确的行为,但当我发布了一个qustion它(延长CakePHP会话Cookie的生命周期)我唯一的答案是我倾向于建议我经历的bahaviour不是默认行为。

At first, I though that this might be the correct behaviour but then when I posted a qustion about it ( Extending the life of the CakePHP Session Cookie ) the only answer I got tended to suggest that the bahaviour I'm experiencing is NOT the default behaviour.

所以,大概我在某处做错了。这是我在APP / Config / core.php:

So, presumably I have done something wrong somewhere. Here is what I've put in APP/Config/core.php:

Configure::write('Session', array(
    'defaults' => 'database',
            'cookie' => 'mycookie',
            'timeout' => 4320 //3 days
));

我只希望cookie在用户上次活动后的3天内保持有效。

I just want the cookie to stay valid for 3 days from the last activity of the user. What it's doing at the moment is expiring after 3 days even if the user has been active the whole time.

推荐答案

我认为你现在正在做的事情会在3天后过期。需要创建自定义会话处理程序 a>达到你的要求。(只需更新会话的过期时间。)

I think you need to create a custom session handler to achieve your requirement.(Just simply update the session's expire when read it.)

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

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