title: Symfony 2 sessions not persisting after created via AJAX call
body: <p>Let me give you the scenario. I have an AJAX call that calls /auth - that page in turn checks if the user is authenticated and sets a couple session variables (code below).</p>
  
  <pre><code>$session = $this-&gt;getRequest()-&gt;getSession();
  
  $session-&gt;set('fbid', $fbid);
  $session-&gt;set('name', $name);
  
  // not sure if this is even needed - get the same with or without
  //$session-&gt;save();
  </code></pre>
  
  <p>Now if I go to another page and try to access that session, it comes back empty.</p>
  
  <p>If I set those sessions on a regular page (not one accessed via XMLHttpRequest/AJAX), it works fine.</p>
  
  <p>Here are my session settings in <code>config.yml</code>:</p>
  
  <pre><code>session:         
      cookie_lifetime:         3600
      cookie_httponly:         false
  </code></pre>
  
  <p>I thought that the problem may have been <code>httponly</code>, but that didn't do it.</p>
  
  <p>Any suggestions? Am I missing something?</p>
  
  <p><strong>* UPDATE *</strong></p>
  
  <p>Here is my security/firewall settings:</p>
  
  <pre><code>firewalls:
      dev:
          pattern:  ^/(_(profiler|wdt)|css|images|js)/
          security: false
  
      login:
          pattern:  ^/demo/secured/login$
          security: false
  
      secured_area:
          pattern:    ^/demo/secured/
          form_login:
              check_path: /demo/secured/login_check
              login_path: /demo/secured/login
          logout:
              path:   /demo/secured/logout
              target: /demo/
  </code></pre>
  
  <p>I haven't changed the firewall settings at all, and from what I can tell, it shouldn't be affecting the <code>/auth</code> call via XMLHttpRequest.</p>
  
  <p><strong>* Update 2 *</strong></p>
  
  <p>I ended up adding <code>$session-&gt;shutdown()</code> after the 2 sets (and yes I know that shutdown isn't a Session object method). It ended up getting an error, but because of that it started working and it actually saved it to $_SESSION. So, if that error forced it to save to $_SESSION, there has to be an actual method that forces the save. Really odd..</p>