title: Setting session variable using ajax
body: <p>I'm using an Ajax call to pass ID to a small php file that just updates a session variable (ID). I then open a new tab using another php file that populates the page with info particular to that ID by referencing it in MySQL. The ajax call is successful. The network traffic shows code 200. I then open the new page in the new tab. But the ID sent never made it to the $_POST['ID'] array element.</p>
  
  <p>The ajax code is triggered by a click event that captures the curr ID value . .</p>
  
  <pre><code>var pkg = {ID:ID};
      $.ajax({
      type: "POST",
      url: "../php-main/updateSessionIDVar.php",
      data: pkg,
      success: console.log("ID value from ajax post:" + ID), // this shows OK
      error:function(jqXHR, textStatus, errorThrown){
          console.log("Error type" + textStatus + "occured, 
          with value " + errorThrown)
          }
      });
  window.open('partEdit.php','_blank');
  </code></pre>
  
  <p>updateSessionIDVar.php file   . . </p>
  
  <pre><code>&lt;?php 
  if (session_status() == PHP_SESSION_NONE) session_start();  
  
  if (isset($_POST['ID'])) {  //this test always fails
      $ID=$_SESSION['currID']=$_POST['ID'];
  }
  else $_SESSION['currID']='63'; // Dummy val so I can test the rest of my code 
  $user=$_SESSION['userID'];    
  ?&gt;
  </code></pre>
  
  <p>Start of php file that makes new page "partEdit.php" . . </p>
  
  <pre><code>&lt;?php   if (session_status() == PHP_SESSION_NONE) session_start(); 
      $ID=$_SESSION['currID'] ;
      $user=$_SESSION['userID'];
  ?&gt;
  &lt;html&gt; etc.
  </code></pre>
  
  <p>I've read several other SO related threads but none seem to fit. Any advice appreciated. </p>