note 19241 added to language.oop.serialization
| From: | grant_mjtr at hotmail dot com | Date: | Wed, 20 Feb 2002 18:15:18 +0000 |
| Subject: | note 19241 added to language.oop.serialization | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26857@lists.php.net to get a copy of this message | ||
A quick note about automatic serialisation in sessions.
If you have an object
$myCart = new ShoppingCart();
and this object contains variables which are objects
function ShoppingCart()
{
$mySingleItem = new BasketItem();
}
this will work fine and you can access the contained object $mySingleItem and its methods etc ONLY
WHILE YOU ARE ON THE PAGE WHERE YOU CREATED IT.
if you are using sessions and register the cart
session_register('myCart')
the ShoppingCart object is serialised and unserialised on the next page ok but the inner BasketItem
object is just garbled.
The only solution I have found is to use an array in the ShoppingCart instead of an object. What a
pain!
--
http://www.php.net/manual/en/language.oop.serialization.php
http://master.php.net/manage/user-notes.php?action=edit+19241
http://master.php.net/manage/user-notes.php?action=delete+19241
http://master.php.net/manage/user-notes.php?action=reject+19241