title: store values in php array/session by ajax in jquery
body: <p>I want to store values in PHP array or PHP session by ajax in jquery 
  I'm sending some values by ajax on a php page and want to store them </p>
  
  <p>Problem : Every time array/session return the latest sent value , not the previous values that i sent<br>
  i  want that previous sent values should retain in array or session </p>
  
  <p>my code is Below </p>
  
  <p>Js File Code</p>
  
  <pre><code>$.ajax({
                  url: "http://domain.com/ajax.php",
                  type:"POST",
                  data: { name : nname , 
                      clas : nclass , 
                      rows : nrows ,
                      cols : ncols , 
                      types : ntype , 
                      check : ncheck , 
                      count : ncldiv
                   },
  
              success: function(data){
               alert(data); 
             }
              });
  </code></pre>
  
  <p>PHP FILE</p>
  
  <pre><code>&lt;?php
          session_start(); 
          $_SESSION['feilds'] = array();    
          $type = $_POST['types'];
          $name = $_POST['name'];
          $class = $_POST['clas'];
          $rows = $_POST['rows'];
          $cols = $_POST['cols'];
          $check = $_POST['check'];
          $count = $_POST['count'];
           $output_string = array('TYPE'=&gt;$type,'NAME'=&gt;$name,'CLASS'=&gt;$class,'ROWS'=&gt;$rows,'COLS'=&gt;$cols,'REQUIRED'=&gt;$check);
          array_push($_SESSION['feilds'] , $output_string );
          print_r($_SESSION['feilds']);
  ?&gt;
  </code></pre>