title: CakePHP set session via AJAX
body: <p>I'm having a lot of trouble working with CakePHP sessions and AJAX. I have an AJAX login that I use <code>Auth-&gt;login()</code> with, and then I add some extra parameters to the end with <code>Session-&gt;write()</code>.</p>
  
  <pre><code>$this-&gt;Auth-&gt;login();
  $this-&gt;Session-&gt;write('Auth.User.id', $user_grab['User']['id']);
  $this-&gt;Session-&gt;write('Auth.User.auth_level', $user_grab['User']['auth_level']);
  $this-&gt;Session-&gt;write('Auth.User.successful', 3);
  </code></pre>
  
  <p>I <strong>am</strong> using <code>Configure::write('Session.checkAgent', false);</code> as per some suggestions I've read.</p>
  
  <p>The problem is any time I set inside this AJAX, it won't be there on any other page load: even if I do the AJAX again, after writing, and just do a read(), the read() will be empty. It's as if it just ignores the AJAX completely. Yet if I:</p>
  
  <pre><code> ...    
  
   $this-&gt;Session-&gt;write('Auth.User.successful', 3);
  
   print_r($this-&gt;Session-&gt;read());
  </code></pre>
  
  <p>I will see what's supposed to be in the session, it just won't truly save. I can save anywhere else in non-ajax parts of the application, even just setting test session data on the index of the site. It persists.</p>
  
  <p>I'm completely stuck. It seems unrelated to using Auth->login(). I am using, in AppController, both Session and Auth.</p>
  
  <p><strong>Expected behavior:</strong> being able to Session->write() in AJAX and have what I wrote be available anywhere else. To test, I was using a test action with a simple debug($_SESSION) and debug($this->Session->read()).</p>