title: creating session array in my shopping cart not functioning
body: <p>hello I am trying to create a simple shopping cart for my school project the problem I have was the session array is not creating and array with information. So I can't add items on my cart. here is my code.</p>
  <pre class="lang-php prettyprint-override"><code>if(isset($_POST['add_to_cart'])) {
      
      if(isset($_SESSION['cart'])) {
          
          $session_array_id = array_column($_SESSION['cart'], 'id');
          
              if(!in_array($_GET['id'], $session_array_id)) {
          $session_array = array(
              'id' =&gt; $_GET['id'],
              'name' =&gt; $_POST['name'],
              'price' =&gt; $_POST['price'],
              'quantity' =&gt; $_POST['quantity']            
          );
          
          $_SESSION['cart'][0]= $session_array;
                  
              }
              
      }else {
          $session_array = array(
              'id' =&gt; $_GET['id'],
              'name' =&gt; $_POST['name'],
              'price' =&gt; $_POST['price'],
              'quantity' =&gt; $_POST['quantity']            
          );
          
          $_SESSION['cart'][] = $session_array;
          
      }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/VYZhd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VYZhd.png" alt="This is what I am getting.. It won't add another session array" /></a>
  the picture above is just overwriting my selection everytime I press add to cart it won't stack up new item on top of the other. so basically the session array stays 0 all the time.</p>
  <p>Pls somebody help me figure this out thank you so much!</p>