I have to migrate a php4 app that uses session_set_save_handler()
to php5.
In php4 everything was fine, but in php5 the callback functions cannot access the global vars anymore, which were set on the page before session_set_save_handler()
was called.
In the example below the global var $g1 cannot be accessed in the session_writer()
(which is passed as a callback function)
Is there some explanation for this behavior or can you give a hint on migrating sessions with callbacks from php4 to 5?
This is the pseudo code:
function session_writer($id,$vars) {
global $g1;
echo "g1 not defined here: ".is_object($g1);
}
global $g1;
$g1 = SomeObject(); //which is the DB connection for the session writer
session_set_save_handler($o,$c,$r,"session_writer",$d,$g);
session_start();