title: how to pass two php session variables via ajax to a another php file
body: <p>I am building a shopping cart and the in the one page where i show the items i have to add a feature for filter the available items for their prices.So i thought to use my session variables to do that but i dont have a proper understand to do it in that way since i am a beginner.But i managed to do it in a hardcoded way.when the user select the check box for price range i make a ajax call and it include the relevant php file after filtering.But since it is not good can any one show me a better way to do that?
  here are my php session variables in item.php file
  <code>include("config.php");
  $dress=$_REQUEST['dress'];
  $catg=$_REQUEST['catg'];
  $subcatg=$_REQUEST['subcatg'];</code></p>
  
  <h2>Here is my ajax code</h2>
  
  <pre><code> &lt;script&gt;
  function showUser()
  {
  
  
  if (window.XMLHttpRequest)
  {
  
  xmlhttp=new XMLHttpRequest();
  }
  else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
  
  
  xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
  {
  document.getElementById("subcat").innerHTML=xmlhttp.responseText;
  }
  }
  //alert(str);
  document.getElementById("xx").checked = false;
  xmlhttp.open("GET","dd.php",true);
  xmlhttp.send();
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <h1>here is my dd.php file u can see ther i hardcoded values for filtering the items in the query</h1>
  
  <pre><code>&lt;?php
  
      include("config.php");   
  //error_reporting(1);
  $catg=$_SESSION['catgg'];
  $subcatg=$_SESSION['subcatgg'];
  
     $sell=mysqli_query($con,"select * from items where catg='2' and subcatg='kurtas'  and price BETWEEN '1000' and '1500'");
     echo"&lt;form method='post'&gt;&lt;table border='0' align='center'&gt;&lt;tr&gt;";
     $nn=0;
      while($arrr=mysqli_fetch_array($sell))
     {
     $i=$arrr['itemno'];
      if($nn%3==0)
      {
      echo "&lt;tr&gt;";
      }
     echo "
     &lt;td height='280' width='240' align='center'&gt;&lt;div class='col-md-3 item-grid simpleCart_shelfItem ' style='width:100%'&gt;
                      &lt;div class=' mid-pop'&gt;&lt;div class='pro-img'&gt;&lt;img src='admin/itempics/$i.jpg'  class='img-responsive' height='200' width='200'&gt;&lt;br/&gt;
  
   &lt;b&gt;Item No:&lt;/b&gt;".$arrr['itemno'].
     "&lt;br&gt;&lt;b&gt;Price:&lt;/b&gt;Rs&amp;nbsp;".$arrr['price'].
     "&lt;br&gt;&lt;b&gt;Description:&lt;/b&gt;".$arrr['desc'].
     "&lt;br&gt;&lt;br&gt;&lt;a href='indexone.php?con=12 &amp; itemno=$i'&gt;&lt;img src='images/MetalPlakDa5new.gif' width='70' height='20'/&gt;&lt;/a&gt;
     &lt;a href='indexone.php?con=14 &amp; itemno=$i'&gt;&lt;img src='images/view7.jpg' width='70' height='20'/&gt;&lt;/a&gt;
     &lt;div class='zoom-icon '&gt;&lt;a class='picture' href='admin/itempics/$i.jpg' rel='title' class='b-link-stripe b-animate-go  thickbox'&gt;&lt;i class='glyphicon glyphicon-search icon '&gt;&lt;/i&gt;&lt;/a&gt;
                          &lt;a href=''&gt;&lt;i class='glyphicon glyphicon-menu-right icon'&gt;&lt;/i&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;";
    $nn++;
  
     }
        echo "&lt;/tr&gt;&lt;/table&gt;
         &lt;/form&gt;";
         ?&gt;
  </code></pre>