title: PHP session variables not preserved with ajax
body: <p>I have a one page website that uses AJAX to load new php files and update the display.</p>
  
  <p>I start my php session on the main page but when I use ajax to update inner html I need those session variables for the new php file being loaded.</p>
  
  <p>This post is similar to this one: <a href="https://stackoverflow.com/q/663442/933756">PHP Session Variables Not Preserved</a> . But I checked and my php.ini has <code>session.use_cookies = 1</code> </p>
  
  <p>Main Page PHP:</p>
  
  <pre><code>&lt;?php 
  session_start();
  if(isset($_SESSION['views']))
  {$_SESSION['views']=$_SESSION['views']+1;}
  else
  {$_SESSION['views']=1;}
  ?&gt;
  </code></pre>
  
  <p>After User Input I use ajax to call a php file and load a subsection of the page:</p>
  
  <pre><code>&lt;?php    
  if(isset($_SESSION['views']))
      { echo "Views: " . $_SESSION['views'];} 
      else 
      { echo "Views: NOT SET";}
  ?&gt;
  </code></pre>
  
  <p>Can someone please tell me what important step I am missing? Thank you.</p>
  
  <p><strong>Update:</strong> After adding session_id() call to both the main and sub pages I see that both pages have the same Session_ID. However it still cannot pull the session variable and if i do assign it a value the two same name session variables stay independent of one another.</p>
  
  <p><strong>Answer to the question that this question created:</strong>  I found that I had to set a static session_save path in my php.ini file. With most paid webhosting services they just have a default container for sessions but it is affected by load balancing. What a releif.</p>