title: PHP session values lost after redirect on one script but preserved after redirection on another
body: <p>On my registration script i have:</p>
  
  <pre><code>// Save registration information into the database
  
  // Set sessions
  $_SESSION['var1'] = 'somevalue';
  $_SESSION['var2'] = 'anothervalue';
  
  header('Location: /somewhere');
  exit();
  </code></pre>
  
  <p>Then on my login script i have:</p>
  
  <pre><code>// Check if user provided correct login credentials
  if (correct) {
      $_SESSION['var1'] = 'somevalue';
      $_SESSION['var2'] = 'anothervalue';
  }
  
  header('Location: /somewhere');
  exit();
  </code></pre>
  
  <p>What happened is that the session variables were lost after the header redirect in the registration script but they were preserved after the redirect in the login script. </p>
  
  <p>I've checked <code>session_id()</code> at both pages and they have the same value, included <code>session_start()</code> at the top of every page and basically tried the solutions to this common problem found on Stackoverflow but somehow nothing seemed to work.</p>
  
  <p>I'm beginning to wonder if it is something to do with my server configuration instead of my code. </p>