title: Cakephp database session destroy handler makes the page unresponded
body: <p>I'm trying to do the database session in my CakePHP application. Everything is fine so far.
  The problem is that when I try to log out, the page is taking too long to respond and got the message "The connection was reset".</p>
  
  <p>Even if my <code>MySession.destory()</code> method contains just a line <code>return true</code>, the problem still exists. I could see the output <code>My Session</code> when I removed the comment from <code>//echo 'MySession'; exit;</code>; </p>
  
  <p>When I removed the line <code>$this-&gt;controller-&gt;Session-&gt;destroy();</code> from <code>MyAuthComponent</code>, it is ok except that the session is not destroyed.</p>
  
  <p>Even if the function <code>MySession.destroy()</code> is empty, the problem persists.
  The following is my code:</p>
  
  <p><strong>app\Config\core.php</strong></p>
  
  <pre><code>Configure::write('Session', array(
      'defaults' =&gt; 'database',
      'handler' =&gt; array(
          'engine' =&gt; 'MySession',
          'model'  =&gt; 'session'
      )
  ));
  </code></pre>
  
  <p><strong>app\Controller\AppController.php</strong></p>
  
  <pre><code>class AppController extends Controller {
    public $components = array(
      "Session",
      "Token",
      "Auth" =&gt; array(
        'className' =&gt; 'MyAuth'
      ),
    );
  </code></pre>
  
  <p><strong>app\Controller\LoginController.php</strong></p>
  
  <pre><code>public function logout() {
      $this-&gt;Auth-&gt;logout();
      $this-&gt;redirect($this-&gt;Auth-&gt;logoutUrl());
  }
  </code></pre>
  
  <p><strong>app\Controller\Component\MyAuthComponent.php</strong></p>
  
  <pre><code>public function logout() { 
      $this-&gt;controller-&gt;Session-&gt;destroy();
      return true;
  }
  </code></pre>
  
  <p><strong>lib\Cake\Model\Datasource\Session\MySession.php</strong><br>
  This extends <code>lib\Cake\Model\Datasource\Session\DatabaseSession.php</code> as I need some customization on this.</p>
  
  <pre><code>public function destroy($id) { 
      //echo 'MySession'; exit;
      //if($this-&gt;cacheKey) Cache::delete($id, $this-&gt;cacheKey);
      //return $this-&gt;_model-&gt;delete($id, false);
      //return parent::destroy($id);
      return true;
  }
  </code></pre>
  
  <p><strong>Model\Session.php</strong></p>
  
  <pre><code>class Session extends AppModel {
    public $useTable = "cake_sessions";
  
    public function __construct(){
      parent::__construct();
    }
  
    public function delete($id){    
        $db = $this-&gt;getDataSource();
        if($db-&gt;delete($this, array($this-&gt;alias . '.' . $this-&gt;primaryKey =&gt; $id))){
            return true;
        }
        return false;
    }
  }
  </code></pre>
  
  <p>My PHP version is 5.2.6 and Cake version is 2.1.3.</p>
  
  <h2>UPDATE on 15 Apr, 2014</h2>
  
  <p>The problem does not occur in XAMPP 1.7.4 with PHP 5.3.5. Probably it is a pitfall of lower version of PHP for session destroy callback.</p>