title: Storing multiple values in session array and retrieving
body: <p>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.</p>
  
  <p>and when the user checkouts i need to retrieve all the productids and display?</p>
  
  <p>can some one please explain me how to do it? coz my array just shows 1 product but not all.</p>
  
  <p>i have also read a post on this platform but that also didnt cux again its storing only variable.. link of that post</p>
  
  <p>[link] (<a href="https://stackoverflow.com/questions/2223846/store-mutiple-values-in-php-session">store mutiple values in php session</a>)</p>
  
  <p>Thanx in advance for help.</p>
  
  <p>Code That I Tried:</p>
  
  <pre><code> $cart=array("p_id"=&gt;"$_SESSION[productid]",
               "p_size"=&gt;"$_SESSION[p_size]",
               "p_qty"=&gt;"$_SESSION[p_qty]");
  
   $_SESSION["cart"]=$cart;
  
  
   foreach ($_SESSION['cart'] as $item) {
   echo $item;
  </code></pre>
  
  <p>}</p>