tiki Posted June 19, 2006 Share Posted June 19, 2006 I have a cart system that uses sessions to track all the items in the cart, and price etc. The cart system uses a global cart class to do all its functions, but whenever you add an item to the cart, it works correctly then the sessions get messed up, why?Test it out here, and add the item, then browse around and it messes up![a href=\"http://www.mileswjohnson.com/clients/Cssbooth/browse/MJ0001GR/1/\" target=\"_blank\"]http://www.mileswjohnson.com/clients/Cssbo...wse/MJ0001GR/1/[/a]The sessions are echoed at the top as so:echo $_SESSION;print_r $_SESSION;print_r $_SESSION["cart"];I get these errors mostly:Fatal error: Call to a member function on a non-object in /home/mileswjo/public_html/clients/Cssbooth/viewcart.php on line 9 Quote Link to comment Share on other sites More sharing options...
poirot Posted June 19, 2006 Share Posted June 19, 2006 To begin with, why are you echoing $_SESSION? You can't use echo with arrays - actually you can but it's not pretty.Then, you don't need to print_r $_SESSION['cart'] if you already printed $_SESSION. And you must use parenthesis when calling functions:print_r($_SESSION);And anyway, your error shouldn't be caused by this, but as result of uninitialized class. (calling $class->method() for example). Quote Link to comment Share on other sites More sharing options...
tiki Posted June 19, 2006 Author Share Posted June 19, 2006 I know how to echo a session, and how to use parenthesis. Im doing that so I see if the session is set and updates itself.I do start the class though.// Start sessionssession_start();header("Cache-control: private");$_SESSION["cart"] = new Cart; Quote Link to comment Share on other sites More sharing options...
poirot Posted June 19, 2006 Share Posted June 19, 2006 [!--quoteo(post=385509:date=Jun 18 2006, 08:42 PM:name=tiki)--][div class=\'quotetop\']QUOTE(tiki @ Jun 18 2006, 08:42 PM) [snapback]385509[/snapback][/div][div class=\'quotemain\'][!--quotec--]$_SESSION["cart"] = new Cart;[/quote]What is line 9 then? Quote Link to comment Share on other sites More sharing options...
tiki Posted June 19, 2006 Author Share Posted June 19, 2006 [a href=\"http://www.mileswjohnson.com/clients/Cssbooth/cart/\" target=\"_blank\"]http://www.mileswjohnson.com/clients/Cssbooth/cart/[/a]This is the error lines, starting at 32.[code]$empty = $_SESSION["cart"]->items(); ?><div class="half"><? if ($empty == 0) { ?> <p class="title">Your cart is empty</p> <p><a href="browse/">Browse</a> our templates and add them to your cart!</p> <? return false; } ?>[/code] Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 19, 2006 Share Posted June 19, 2006 a href="browse/">Browse</a>wrong { link }?.phpwtfthe link missing exstention .php Quote Link to comment Share on other sites More sharing options...
tiki Posted June 19, 2006 Author Share Posted June 19, 2006 Wtf are u talking about? Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 19, 2006 Share Posted June 19, 2006 [!--quoteo(post=385537:date=Jun 19 2006, 05:48 AM:name=tiki)--][div class=\'quotetop\']QUOTE(tiki @ Jun 19 2006, 05:48 AM) [snapback]385537[/snapback][/div][div class=\'quotemain\'][!--quotec--]Wtf are u talking about?[/quote]post whole page Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.