【发布时间】:2016-09-29 08:29:21
【问题描述】:
我正在开发一个使用 CakePHP 2.8 构建的项目。在登录时,我将 FLAG 设置为 1,在注销时将其设置为 0,以便该帐户一次可以在单台计算机上登录。在这部分之前它工作得很好。
我面临的问题是会话超时。我很困惑当会话超时时如何在数据库中将标志设置为 0。有什么方法可以在会话超时时运行更新查询。
我正在使用 CORE 配置文件来设置 SESSION 超时限制,如下所示:
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
));
这是我的注销功能
public function logout() {
$id = $this->Auth->User('id');
$this->User->updateAll(array('WebLoggedIn'=>0), array('User.id'=>$id));
$this->Auth->logout();
// redirect to the home
return $this->redirect('/');
}
【问题讨论】:
-
请查看stackoverflow.com/questions/37948391/…。你可以在这里做一些回答
标签: php session cakephp model-view-controller session-timeout