When I launch the following code for the third time I have this error:
Fatal error: Call to a member function on a non-object in .../test.php on line 29 [echo($test->get_data());]
This happen only if register_global is ON
I have noticed that the content of $_SESSION['test'] became an object and not a string.
Help me please!
<?php
class test
{
var $var = 0;
function test()
{
if (!isset($_SESSION['test']))
{
// store new test object in session data
$this->var = 1;
$_SESSION['test'] = serialize($this);
}
else
{
//wake-up existing forum object
$this = unserialize($_SESSION['test']);
}
}
function get_data()
{
return $this->var;
}
}
session_start();
$test = new test();
echo($test->get_data());
?>