I am writing a script in php, which is quite similar to a shopping cart. what i want to do is when a users adds a certain product i need to add the productid,product quantity and product size to a session array,without storing in a database. So each time the user adds a product the productid needs to be stored in a session variable.
and when the user checkouts i need to retrieve all the productids and display?
can some one please explain me how to do it? coz my array just shows 1 product but not all.
i have also read a post on this platform but that also didnt cux again its storing only variable.. link of that post
[link] (store mutiple values in php session)
Thanx in advance for help.
Code That I Tried:
$cart=array("p_id"=>"$_SESSION[productid]",
"p_size"=>"$_SESSION[p_size]",
"p_qty"=>"$_SESSION[p_qty]");
$_SESSION["cart"]=$cart;
foreach ($_SESSION['cart'] as $item) {
echo $item;
}