Created
March 14, 2014 16:32
-
-
Save masihyeganeh/9551308 to your computer and use it in GitHub Desktop.
Weird PHP session lock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
set_time_limit(0); | |
session_start(); | |
print $_SESSION['something']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
set_time_limit(0); | |
session_start(); | |
$_SESSION['something'] = 0; | |
for ($i=0; $i < 1000; $i++) { | |
$_SESSION['something']++; | |
sleep(10); | |
} |
OK, found the solution:
<?php
set_time_limit(0);
session_start();
$_SESSION['something'] = 0;
session_write_close();
for ($i=0; $i < 1000; $i++) {
session_start();
$_SESSION['something']++;
session_write_close();
sleep(10);
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If we execute
writer.php
,reader.php
won't load until writer finishes completely