Skip to content

Instantly share code, notes, and snippets.

@renan
Created September 21, 2012 14:25
Show Gist options
  • Save renan/3761745 to your computer and use it in GitHub Desktop.
Save renan/3761745 to your computer and use it in GitHub Desktop.
Session Locking
# Make sure you copy-paste all commands, so there is no delay between them
wget -q http://localhost/test.php -O first.txt &
sleep 1s
wget -q http://localhost/test.php -O second.txt
cat first.txt second.txt
3.1705009937286
5.171688079834
The second request will be always take 2 seconds more to finish, because its waiting for the first request to be completed.
<?php
session_id('sessionConcurrentTest');
session_start();
sleep(3);
echo (microtime(true) - $_SERVER['REQUEST_TIME']) . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment