RE: [PHP] PHP Classes and Sessions

From: Date: Tue, 05 Feb 2002 05:33:28 +0000
Subject: RE: [PHP] PHP Classes and Sessions
Groups: php.general 
Request: Send a blank email to php-general+get-83529@lists.php.net to get a copy of this message
i believe you're meant to serialise objects and then register the serialised version?? Don't quote me on that, never used sessions, but I didn't read/hear it somewhere Martin -----Original Message----- From: PHP-List [mailto:PHP-List@fc.emc.com.ph] Sent: Tuesday, February 05, 2002 4:30 PM To: php-general@lists.php.net Subject: [PHP] PHP Classes and Sessions What is the proper way to transfer class properties through-out my pages... let's say i have a ShoppingCart Class and i have methods like addToCart(id, qty) and deleteFromCart(id) also i have properties like CartItems("id" => array(), "qty"=> array()) this is what i do... //when the user enters my site, i do some... ------------- if (!session_is_registered("myCart")){ $myCart = new ShoppingCart(); .... (some other stuffs...) session_register("myCart"); } else { $myCart = new ShoppingCart(); } -------------- if the object in the session is not present i would create an instance and then register it to the session. else if it is present, i would just reconstruct it... because if i don't, even though it is in the sessions, the properties and methods are not constructed (no handler, i don't know how to call it). my code works, but is there any other way to do this, because i think it's kinda slow.... another question, is it ok to have a database-driven shopping cart? i make use of the database to as the actual cart holder? i need your opinions on these.... thanks! Brian Feliciano -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#83529) next »