session_write_close does not appear to be freeing the file lock.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • seye.ojumu@gmail.com

    session_write_close does not appear to be freeing the file lock.

    Hello,

    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_c lose() 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.

    <?php
    error_reporting (E_ALL);

    $herebefore = 0;

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

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

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

    $i++;
    }

    ?>

    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) ..."

    Thanks

Working...