title: How to delete items from cart through SESSION & AJAX in php
body: <p>I am trying to remove items from cart through ajax. I am getting evrything like particular id and data in session but when i apply unset() then it is not delete that particular row. It is deleting whole cart</p>
  <p>Here is my Ajax file Code:</p>
  <pre><code>&lt;?php
      session_start();
      // echo '&lt;pre&gt;'; print_r($_POST);
      // echo '&lt;pre&gt;'; print_r($_SESSION);
  
      foreach($_SESSION[&quot;shopping_cart&quot;] as $product) {      
          foreach($product as $reportProduct) {
            foreach($reportProduct as $data) {
              if($data['id'] == $_POST['report_id']) {
                  unset($_SESSION['shopping_cart']);  // Now how to unset that particular id session
              }
            }
          }
      }
  ?&gt;
  </code></pre>
  <p>Here is my Cart Session Array, having two items in my cart (i.e)
  print_r($_SESSION['shopping_cart']);</p>
  <pre><code>Array
  (
      [shopping_cart] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [0] =&gt; Array
                          (
                              [] =&gt; Array
                                  (
                                      [id] =&gt; 3
                                      [name] =&gt; Abbvie Emissions Report
                                      [price] =&gt; 1999.00
                                      [quantity] =&gt; 1
                                  )
                          )
                  )
  
              [1] =&gt; Array
                  (
                      [0] =&gt; Array
                          (
                              [] =&gt; Array
                                  (
                                      [id] =&gt; 4
                                      [name] =&gt; Abbvie Emissions Report
                                      [price] =&gt; 1999.00
                                      [quantity] =&gt; 1
                                  )
                          )
                  )
          )
  )
  </code></pre>