0

Hi, all
i want to have the "add to cart" function in my website which use session function:
Well basically the cart is mostly like others website cart: remember which have already been added and could add something more

Assume i have class.php, A.php and B.php
In my A.php

<?php
require_once("classes.php");
session_start();
$item = new Item($id, (string)$itemXML[0]->name, $quatity, $catalog);//Item is the class i define in class.php
$_SESSION['cart'][$id] = $item;//// Add the item to the $_SESSION['cart'] session variable
?>

In my B.php

<?php
require_once("classes.php");
session_start();
$cart = $_SESSION['cart'];
foreach($cart as $item) 
{

//do the array loop
}

?>

So i got the error and warnings information:
Fatal error: Cannot use object of type Item as array
warnings: session-start function: Node no longer exists and Cannot send session cache limiter

Thanks in advance and BOW!!

1
Contributor
1
Reply
2
Views
8 Years
Discussion Span
Last Post by shasha821110
0

sorry, changed A.php code:

<?php
require_once("classes.php");
session_start();
$id = $_GET['id'];
$itemXML = $xml->xpath("/root//item[@id='{$id}']");
$item = new Item($id, (string)$itemXML[0]->name, $quatity, $catalog);//Item is the class i define in class.php
$_SESSION['cart'][$id] = $item;//// Add the item to the $_SESSION['cart'] session variable
?>

Thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.