title: Showing session array value by foreach looping
body: <p>I want to show all stored data in my session in using foreach looping. I can't show it. Can anybody please give me an idea on how to show stored value. I need to show PRODUCT ID and INFO  of each added product. Here is the code - `</p>
  
  <pre><code>&lt;?php
  session_start();
  /*
  TEMPLATE NAME: Cart Page
  */
  </code></pre>
  
  <p>?></p>
  
  <pre><code>&lt;?php
      $git_product_id = $_POST['git_product_id'];
      $git_required = $_POST['git_required'];
      $git_action = $_POST['git_action'];
  
      if ( isset($git_product_id)){
  
          switch($git_action){
  
              case "add" :
                  // adding product
                      // checking first if the product is already added
                      if (isset($_SESSION['cart'][$git_product_id])){
                          echo "You have already added this product";                     
                      } else {
                          // I AM NOT SURE IF THIS CODING IS OKAY. PLEASE CHECK THIS
                          if (!isset($_SESSION['cart'])) {
                            $_SESSION['cart'] = array();
                          }
                          $_SESSION['cart'][$git_product_id] = array('product_id' =&gt; $git_product_id, 'info' =&gt; $git_required);
  
                      }
              break;
  
              case "remove":
                  // removing product
                  unset($_SESSION['cart'][$git_product_id]);
              break;
  
              case "empty" :
                  // empty cart
                  unset($_SESSION['cart']); 
              break;              
  
          } 
      }
  ?&gt;
  
  &lt;?php 
  
      if ($_SESSION['cart'] != ""):
          foreach($_SESSION['cart'] as $product =&gt; $key ) : ?&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;?php // I WANT TO SHOW HERE EACH PRODUCT ID and RESPECTIVE REQUIRED INFO ?&gt;
                  &lt;?php // BUT I DON'T KNOW HOW TO DO IT ?&gt;
              &lt;/td&gt;
  
              &lt;td&gt;
                  &lt;form action="" method="post"&gt;
                      &lt;input type="hidden" name="git_product_id" value="&lt;?php echo $product; ?&gt;" /&gt;
                      &lt;input type="hidden" name="git_required" value="&lt;?php echo $qty; ?&gt;" /&gt;
                      &lt;input type="hidden" name="git_action" value="remove" /&gt;
                      &lt;input type="submit" value="Remove" /&gt;
                  &lt;/form&gt;
              &lt;/td&gt;
  
          &lt;?php endforeach; ?&gt; 
      &lt;?php endif; ?&gt;
  
      &lt;form action="" method="POST"&gt;
          &lt;input type="hidden" name="git_product_id" value="&lt;?php echo $product; ?&gt;" /&gt;
          &lt;input type="hidden" name="git_required" value="&lt;?php echo $qty; ?&gt;" /&gt;
          &lt;input type="hidden" name="git_action" value="empty" /&gt;
          &lt;input type="submit" value="empty" /&gt;
      &lt;/form&gt;             
  </code></pre>