title: Session regenerate causes expired session with fast AJAX calls
body: <p>My application is a full AJAX web page using Codeigniter Framework and memcached session handler.</p>
  
  <p>Sometimes, it sends a lot of asynchronous calls and if session has to regenerate its ID (to avoid session fixation security issue), the session cookie is not renewed fast enough and some AJAX calls fail due to session id expired.</p>
  
  <p>Here is a schematic picture I made to show clearly the problem :
  <a href="https://i.stack.imgur.com/XD5No.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/XD5No.jpg" alt="enter image description here"></a></p>
  
  <p>I walked across the similar threads (for example <a href="https://github.com/bcit-ci/CodeIgniter/issues/154" rel="noreferrer">this one</a>) but the answers doesn't really solve my problem, I can't disable the security as there is only AJAX calls in my application.</p>
  
  <p>Nevertheless, I have an Idea and I would like an opinion before hacking into the Codeigniter session handler classes :
  The idea is to manage 2 simultaneous session Ids for a while, for example 30 seconds. This would be a maximum request execution time. Therefore, after session regeneration, the server would still accept the previous session ID, and switch to session to the new one.
  Using the same picture that would give something like this : </p>
  
  <p><a href="https://i.stack.imgur.com/52dnR.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/52dnR.jpg" alt="enter image description here"></a></p>