Cakephp数据库会话销毁处理程序使页面无响应

时间:2014-04-09 10:44:39

标签: php session cakephp

我试图在CakePHP应用程序中进行数据库会话。到目前为止一切都很好。 问题在于,当我尝试注销时,页面响应时间过长并收到消息"连接已重置"。

即使我的MySession.destory()方法只包含一行return true,问题仍然存在。当我从My Session删除评论时,我可以看到输出//echo 'MySession'; exit;;

当我从$this->controller->Session->destroy();删除行MyAuthComponent时,除了会话未被销毁外,它是正常的。

即使函数MySession.destroy()为空,问题仍然存在。 以下是我的代码:

应用\配置\ core.php中

Configure::write('Session', array(
    'defaults' => 'database',
    'handler' => array(
        'engine' => 'MySession',
        'model'  => 'session'
    )
));

应用\控制器\ AppController.php

class AppController extends Controller {
  public $components = array(
    "Session",
    "Token",
    "Auth" => array(
      'className' => 'MyAuth'
    ),
  );

应用\控制器\ LoginController.php

public function logout() {
    $this->Auth->logout();
    $this->redirect($this->Auth->logoutUrl());
}

应用\控制器\元器件\ MyAuthComponent.php

public function logout() { 
    $this->controller->Session->destroy();
    return true;
}

LIB \蛋糕\模型\数据源\会话\ MySession.php
这扩展了lib\Cake\Model\Datasource\Session\DatabaseSession.php,因为我需要对此进行一些自定义。

public function destroy($id) { 
    //echo 'MySession'; exit;
    //if($this->cacheKey) Cache::delete($id, $this->cacheKey);
    //return $this->_model->delete($id, false);
    //return parent::destroy($id);
    return true;
}

模型\ session.php文件

class Session extends AppModel {
  public $useTable = "cake_sessions";

  public function __construct(){
    parent::__construct();
  }

  public function delete($id){    
      $db = $this->getDataSource();
      if($db->delete($this, array($this->alias . '.' . $this->primaryKey => $id))){
          return true;
      }
      return false;
  }
}

我的PHP版本是5.2.6,Cake版本是2.1.3。

2014年4月15日更新

使用PHP 5.3.5在XAMPP 1.7.4中不会出现此问题。对于会话销毁回调,可能是PHP较低版本的缺陷。

0 个答案:

没有答案