Matthew Bates schrieb:
Hi,
I'm currently building an object-oriented shopping cart with PHP 4.3.2 and
MySQL 4.0.14.
I am looking at storing a Cart object within a PHP session, however I am not
completely sure on the best way to achieve this. I have read up and there
seems to be varying advice. Should I need to serialise and unserialise the
object or is this automatic and should I be using session_register()? For
reference, register_globals is off.
I'd be grateful if anybody could help.
Thanks in advance,
Matt
With your PHP version, storing objects in the session should work quite
easy - just set
$_SESSION["cart"] = $your_card_object;
i.e., no serizalize/unserialize is necessary.
One problem may occure when you will retrive the object from the session
- you need to include the class definition before the session starts!
But I found it easier to store only object IDs in the session and to
store/retrieve the object itself from the database.
Regards!
Rainer
--
------------------------------------------------
Rainer Herbst Linux - Registered
ZEIK User #319157
Universität Potsdam Usual disclaimers applies!
------------------------------------------------