You are here: session_write_close does not appear to be freeing the file lock. « PHP Programming Language « IT news, forums, messages
session_write_close does not appear to be freeing the file lock.

Posted by seye.ojumu@gmail.com on 03/19/07 16:41

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_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.

<?php
error_reporting(E_ALL);

$herebefore = 0;

session_start();
if (isset($_SESSION["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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация