title: PHP sessions not persisting on Amazon EC2
body: <p>I am currently working on a Facebook application that runs on Amazon EC2. The app is working and most development is complete, however we cannot get sessions to persist. We have tried PHP default session handling, database handling and memcache handling using the PHP session save_path trick. We've tried messing with ini settings like auto_start, no avail.</p>
  
  <p>The weird problem is that the initial session write DOES write, but any subsequent write after the first does not save. We can see the session cookie persisting, but the actual writing of data always fails after the first write. This weird problem applies to any session handler we use.</p>
  
  <p>Our EC2 setup is as follows:</p>
  
  <ul>
  <li>Dev: 1 64bit linux server, 1 mongodb server, 1 elasticache cluster</li>
  <li>Staging: 1 64bit linux server, 1 mongodb server, 1 elasticache cluster</li>
  <li>Prod: 2 64bit linux servers with 1 load balancer, 3 mongodb servers with replicaset, 2 elastic ache clusters</li>
  </ul>
  
  <p>The session problem is reproducable in all environments. I am running out of ideas here as I have tried everything I know and anything I found while Googling.</p>
  
  <p>For reference we are using CakePHP 2.1, but have also tried sessions outside of CakePHP.</p>