Session object
10
I'm trying to load an object into a session variable.
Here's my code:
if(!isset($_SESSION['tree'])) {
$_SESSION['tree'] = new DBTree();
}
echo $_SESSION['tree']->sizeOf();
If the session variable isn't set, then it gets set and the echo works fine. But let's say I refresh the page, so the session variable is already set, so it skips the if statement, but the echo statement fails with error: "The script tried to execute a method or access a property of an incomplete object."
Any help? 





else
{
unserialize($_SESSION['object']);
}
Thought there is no warranty this will work, my opinion is that it won't work since you are trying to use a variable which is pointing to an object which might or might not be there or the object might have changed since last time. What if the user comes back after some time when you have changed the class, but the object you saved in the session is the old one (which now breaks other functions as it doesn't work as the update class).
Use $localVar = new myClass; instead.
-----------------------
http://jiart.org/
My digital playground with it's own sandbox.
Well anyway, I love programming