title: how to add multiple items to cart with cookies method
body: <p>when i add second item to the cart , the first item will be replaced<br>
  this is my code(cart.php)</p>
  
  <pre><code>&lt;?php 
      include"connect.php";
   ?&gt;
  
  &lt;?php
     $total=0;
  $variety = $quantity = $bran = "";
  
  if(isset($_COOKIE['cart']))
  {
  $cookie = $_COOKIE['cart'];
  $cookie = stripslashes($cookie);
  $savedCardArray = json_decode($cookie, true);
  foreach ($savedCardArray as $key =&gt; $value) {
      $variety=$savedCardArray[$key][0];
      $quantity=$savedCardArray[$key][1];
      $bran=$savedCardArray[$key][2];
      $total = $quantity*998;
      setcookie('total', $total);
  }
  
  }
  ?&gt;
  </code></pre>
  
  <p>the cart_update page is given below</p>
  
  <pre><code>&lt;?php
  class CartUpdate 
  {
  
      /**
       * Initialize the Cart.
       * @return void
       */
      public function __construct() {
  
          if(isset($_COOKIE['cart'])) {
  
              $cookie = $_COOKIE['cart'];
              $cookie = stripslashes($cookie);
              $savedCardArray = json_decode($cookie, true);
  
           }
      }
  
  
      function add()
      {
          $variety = test_input($_POST["variety"]);  
          $rice_type = test_input($_POST["rice_type"]);
          $quantity = test_input($_POST["quantity"]);
          $bran = test_input($_POST["bran"]);
          $items[]=array($variety,$quantity,$bran,$rice_type);
          $json = json_encode($items);    
          setcookie('cart', $json);
      }
  </code></pre>
  
  <p>i need all selected items in cart with this cookies method.
  could anyone help me??</p>