title: PHP session destroyed / lost after header
body: <p>I've got a script that sets some session values before redirecting to <code>/</code> using <code>header()</code>.</p>
  
  <p>I've read many posts about the <code>$_SESSION</code> variable being destroyed / lost after <code>header()</code>, even after I implemented this:</p>
  
  <pre><code>// set session here
  
  session_regenerate_id(true);
  session_write_close();
  header("Location: /");
  </code></pre>
  
  <p><code>session_start()</code> is set in the correct places, does anyone know of anything that I might be missing?</p>
  
  <p>On the index.php page I have this:</p>
  
  <pre><code>session_start();
  print_r($_SESSION);
  
  // outputs nothing :'(
  </code></pre>
  
  <p>The code is pretty complex so will not post it all, just snippets.</p>