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!!

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.