Failing session based cart using AJAX to update

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Simmo
Forum Newbie
Posts: 6
Joined: Tue Aug 21, 2007 9:46 am

Failing session based cart using AJAX to update

Post by Simmo »

I have a session based shippong cart which is updated via an AJAX call. In my IDE (PHpED) it works fine, but in production it fails when I try to add another item to the cart and it fails on this line ... if (isset($_SESSION['cart'][$id])) {do something} All it is doing is saying if the part is already in the cart then update the qty else add the new part.

All .php files start with session_start()

Error msg: Fatal error: Cannot use object of type ShoppingCart as array in /home/grahamsi/public_html/test/oas/includes/class_shopping_cart.php on line 47

The session should end up with $_SESSION['cart']['partnumber1'].id or .price or .name or .qty in it.

I don't want to store the cart in MySQL. I do store the cart in a cookie and I suppose I could update the cookie after every cart transaction and reload the cookie before each transaction but should I have to?

Many thanks for any help provided.
Post Reply