note 19241 deleted from language.oop.serialization by danbrown

From: Date: Sat, 07 Nov 2009 19:13:22 +0000
Subject: note 19241 deleted from language.oop.serialization by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162617@lists.php.net to get a copy of this message
Note Submitter: grant_mjtr at hotmail dot com ---- 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!

« previous php.notes (#162617) next »