I have made a dummy session handler class while learning how sessions in php work.
I have the normal:
open, close, read, write, destroy and gc functions inside this class.
I have passed the class to a handler (when the class is created in has one parameter which is the db connection):
$handler = new Session($testdb);
session_set_save_handler(
array($handler,'open'),
array($handler,'close'),
array($handler,'read'),
array($handler,'write'),
array($handler,'destroy'),
array($handler,'gc')
);
session_start();
All of the functions inside this class have worked well - passing the data back and forth to the custom database as planned, accept the garbage collection. the gc function does not seem to want to play ball. When manually called it will work fine but php never seems to call it.
code block of the gc function:
Public function gc($expire)
{
$SessionInfo = new Delete($this->WebSite,array($expire),
"DELETE FROM sessions
WHERE DATE_ADD(LastAccessed, INTERVAL $expire SECOND) < NOW()
");
echo '<H1>BIG LETTERS</H1>'; // HTML shout out if function is called //
return true;
}
I know there is a 1% chance on each session_start() that this is called but i have adjusted the % chance in my php.ini file so as to increase the chances to more 50% and tried several times to get this to actual be used. The fact that the function works fine when manually called and the fact that the other functions in the class work as they should ... leads me slighly stuck ... any ideas?