i am trying to build a simple online shopping cart. Been strugling with 2 dimensional sessions array and when i finally got it working the session array is not updating.
I want to be able to browse through each product page and keep adding the productid,quantity to $_session[cart].
But each time i add to cart the previous product ids and quantities are deleted from the session. Am i doing it correctly.
Somebody please help.Thanks in advance.
Here is my code:
foreach($_POST as $var => $value)
if($value != '')
// add to session
$_SESSION['cart'][$var] = $value;
foreach($_SESSION['cart'] as $pid => $qty)
echo "Product id: $pid, Quantity:$qty ";
0 · ·