You are here: Re: Garbage collector problem with sessions « PHP Programming Language « IT news, forums, messages
Re: Garbage collector problem with sessions

Posted by deciacco on 09/04/07 19:00

Still does not work. Below is the updated code. (This is the Windows
code. The linux code just changes the slashes) I can see the session
file being created, but it never gets deleted. I don't get any errors
with the E_ALL setting. After I start the session the first time, if I
keep refreshing before the 5 seconds are up, the session stays alive as
it should. After 5 seconds the file should be deleted by the GC and the
file_exists($filepath) should return false. This is the behavior on
linux but not on windows. The permissions are set correctly for the
sessions folder. The IUSR has full modify access, so I'm pretty sure
it's not a permissions issue. This is a win 2k3 box with ntfs and
filemtime() works fine. I've even tried a custom session handler storing
to a database, and I get the same behavior.

Could this be a bug?

****************************
<?php
error_reporting(E_ALL);

$sessdir = ini_get('session.save_path')."\\session_testing";

if (!is_dir($sessdir)) {
mkdir($sessdir);
}

ini_set('session.save_path', $sessdir);
ini_set('session.gc_probability', 100);
ini_set('session.gc_divisor', 100);
ini_set('session.gc_maxlifetime', 5);

session_start();

if(isset($_SESSION['isalive']))
{
echo <<<END
Now wait for 5 seconds and refresh twice.<br><br>

On the first refresh the "Session Established"
line will dissapear<br>
because the session data(file)
is deleted by the GC.<br><br>

On the second refresh a new session
will be created and the 'isalive'<br>
session varible set again.<br><br>

If you keep refreshing before the 5 seconds are up<br>
the session doesn't die becuse the session date(file)<br>
never has a chance to expire.<br><br>
END;

$filepath = ini_get('session.save_path')
.'\\sess_'.session_id();

if(file_exists($filepath))
{
$filetime = filemtime ($filepath);
$timediff = mktime() - $filetime;
echo 'Session Established: '
.$timediff.' seconds ago<br><br>';
}
}else{
echo "Setting session variable isalive....";
$_SESSION['isalive'] = true;
echo "<br>Set!...Now refresh...";
}
?>
***********************



Vladimir Ghetau wrote:
> can you add error_reporting (E_ALL) at the begining of the script and
> see what happens?
>
>
> Plus, how about this line:
>
>> mkdir($sessdir, 07777);
>
> Plus, (even if modes are ignored in Windows) it seems the writing
> permissions are written incorrectly.
>
> Next thing,
>
>> $sessdir = ini_get('session.save_path')
>> ."/session_testing";
>
> Probably session.save_path outputs something like:
>
>> drive:\php_folder\tmp/session_testing
>
> *** see the slashes difference? try to switch the slashes based on the
> OS you're using.
>
> Everything should be ok at this step.
>
>
> Best luck!
>
> Vladimir Ghetau
>
>
>
>

 

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

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