title: set php $_SESSION variable in AJAX
body: <p>sorry for question, there are examples but I can not get it. My code does not work. My test.php file:</p>
  
  <pre><code>&lt;?php
  session_start();
  ?&gt;&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;button onclick="doTheFunction();"&gt;Run the script&lt;/button&gt;
  &lt;script&gt;
  function doTheFunction(){
      xmlhttp = new XMLHttpRequest();
      xmlhttp.open("POST","set.php",true);
      xmlhttp.send();
  }
  &lt;/script&gt;
  &lt;?php echo $_SESSION['w'];?&gt; /*after button onclick and page refresh session 
  shoud be set*/
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My set.php file:</p>
  
  <pre><code>&lt;?php
  session_start();
  $_SESSION['w'] = 'abc';
  ?&gt;
  </code></pre>
  
  <p>Session was not set :/</p>