session_write_close does not appear to be freeing the file lock.

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


I'm trying to nail down an issue and I'm not entirely sure what is
wrong. It is this "loading pages that share a session problem." The
solution, as I've read many places, should be to include a call to
session_write_close() in my script when I'm done reading or writing
the session dictionary. My understanding is that this call releases
the session handle and allows other pages that want to get at the
session to start executing.

The problem is that I don't think I'm not getting this desired
behavior; PHP seems to be blocking on the session_start() call.

This script illustrates my problem.


$herebefore = 0;

if (isset($_SESSION["foo"])) {
  $herebefore = 1;
} else {
  $_SESSION["foo"] = 1;

if ($herebefore) {
  echo "You've been here before!<br>";
} else {
  echo "First visit!<br>";

$i = 0;
while ($i < 20) {
  echo $i;
  echo "<br>";



In FFox 2.0, I open this file in two tabs. Whichever tab was opened
first finishes executing before the second tab begins executing. Now,
a ton of people have said that this works -- in particular before
large file transfer -- so there's a massive, distributed conspiracy or
I must be doing something slightly stupid.

Could someone, anyone, please, shed a little light on why I might be
getting this behavior?

My version of PHP -- though I don't think this should matter: php -v
starts with "PHP 5.0.5-2ubuntu1.5 (cli) ..."


Site Timeline