title: PHP: session isn't saving before header redirect
body: <p>I have read through the php manual for this problem and it seems quite a common issue but i have yet to find a solution. I am saving sessions in a database. 
  My code is as follows: </p>
  
  <pre><code>// session
  $_SESSION['userID'] = $user-&gt;id;        
  header('Location: /subdirectory/index.php');
  </code></pre>
  
  <p>Then at the top of index.php after the <code>session_start()</code>, i have var_dumped the $_SESSION global and the userID is not in there. As i said ive looked through the PHP manual (<code>http://php.net/manual/en/function.session-write-close.php</code>) and neither <code>session_write_close</code> or <code>session_regenerate_id(true)</code> worked for me. 
  Does anybody know a solution? </p>
  
  <p>Edit: I have session_start() at the top of my file. When i var_dump the session global before the header redirect, i see the userID in there, but not in the other file, which is in a subdirectory of this script</p>