title: CakePHP: Session->write() not working
body: <p>I'm building a very basic auth system for specific pages which require a password to view. I've found several other questions that sound similar, but the only ones with clear solutions involve config settings that don't seem to resolve my problem. For some reason <code>$this-&gt;Session-&gt;write(...)</code> always returns false.</p>
  
  <p>Here's my config setting:</p>
  
  <pre><code>Configure::write('Session', array(
      'defaults' =&gt; 'php'
  ));
  </code></pre>
  
  <p>Here's where I try to write the session in the controller action:</p>
  
  <pre><code>private function _handle_auth_attempt( $object ) {
      $submitted_pass = $this-&gt;request-&gt;data['Object']['password'];
      $correct_pass = $object['Object']['password'];
      $auth_cookie_name = $this-&gt;Object-&gt;auth_cookie_name($object);
  
      debug($auth_cookie_name); //'Object1.pass'
      debug($submitted_pass); //'foobar'
  
      if ( md5($submitted_pass) == md5($correct_pass) ) {
          $write1 = $this-&gt;Session-&gt;write( $auth_cookie_name, md5($submitted_pass) );
          $write2 = CakeSession::write( $auth_cookie_name, md5($submitted_pass) );            
          debug($write1); //FALSE
          debug($write2); //FALSE
          return TRUE;
      }
  
      $this-&gt;Session-&gt;setFlash('The password you entered is incorrect.');
      $this-&gt;redirect( $this-&gt;referer() );
  
  }
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>Inside <code>_handle_auth_attempt()</code> I added:</p>
  
  <pre><code>$_SESSION['foo'] = 'bar';
  $this-&gt;Session-read('foo'); //'bar'
  </code></pre>
  
  <p>...and they work fine. So I'm pretty sure this isn't a permissions problem.</p>