As the title suggests, I'm having a problem getting this to work at all.
I believe I need to serialize when storing and unserialize when retrieving the object from $_SESSION
So I would have thought the following would have worked...
I would have thought that objB == obj in the above
Yet when I pull the object out the other end of the session, it has lost the values, like it never serialized. I'm not getting any errors either. I also tried casting, like in other languages...
This gives me errors, but the usual syntax errors you'd get from something misplaced. What am I missing?, do I need to change something in the environment?
I believe I need to serialize when storing and unserialize when retrieving the object from $_SESSION
So I would have thought the following would have worked...
Code:
require_once('MyClass.ClassDef.php');
$obj = new MyClass();
$someval = $obj->getVal();
[B]$_SESSION['myobj'] = serialize($obj);
$objB = unserialize($_SESSION['myobj']);[/B]
$some_other_val = $objB->getVal();
//etc
Yet when I pull the object out the other end of the session, it has lost the values, like it never serialized. I'm not getting any errors either. I also tried casting, like in other languages...
Code:
$objB = (MyClass)unserialize($_SESSION['myobj']);