Async AJAX and PHP session

Javascript is single threaded.  AJAX allows asynchronous calls.


If you use sessions in the AJAX handling functions, you will run in to an issue where the disk session data is locked by the first request, so each subsequent request ends up waiting for the session data to be available before it proceeds. In effect, this makes asynchronous calls block one another, you end up with linear responses to the requests in chronological order – synchronous.

!important:  a form submission can cancel the ajax call.  A form submission can also refresh the page after ajax result is displayed.