I am trying to serve two near simultaneous requests originating from the same browser session.
Consider the following minimal example:
<?php
session_start();
$sessionId = session_id();
session_write_close();
$file = sys_get_temp_dir() . '/lock_test';
if (!file_exists($file)) {
touch($file);
sleep(5);
unlink($file);
echo 'done! ' . $sessionId;
} else {
echo 'locked! ' . $sessionId;
}
The second request should result in the "locked" output but it always waits for the first request to complete and then outputs "done".
Xdebug is not running. PHP version is 5.5.
Edit:
Voting to close this as a duplicate. The linked question suggests that to get around this issue, append a random variable. So I would suggest appending a requestTime variable and setting it to a timestamp with microseconds.