Re: PHP Classes and Sessions
| From: | Yasuo Ohgaki | Date: | Tue, 05 Feb 2002 06:25:16 +0000 |
| Subject: | Re: PHP Classes and Sessions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-83539@lists.php.net to get a copy of this message | ||
Php-List wrote:
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")){You are not following session manual page... You are over writing $myCart with second "new" statement. You don't need it and your can use $myCart if ShoppingCart class definition is included before starting session. -- Yasuo Ohgaki Please CC me when you reply to news/list messages. Do not reply only to me :)$myCart = new ShoppingCart(); .... (some other stuffs...) session_register("myCart");} else {$myCart = new ShoppingCart();}