title: Reopening a session in PHP
body: <p>How do I reopen a session in PHP without getting header already sent warnings?</p>
  
  <p>After setting all the session vars I like to set, I close the session with <a href="http://www.php.net/manual/en/function.session-write-close.php" rel="noreferrer">session_write_close()</a>. I do this, because as long as the session is open, there may be only one active connection from the same client. But I like to have multiple parallel ones.</p>
  
  <p>However if I like to set another session variable at a later point, I need to reopen the session with <a href="http://www.php.net/manual/en/function.session-start.php" rel="noreferrer">session_start()</a> once again. This works, but as I already send code to the client it prints "headers already sent"-warnings. Why is it trying to set the cookie again? The cookie is already set. Only thing I need is to gain access to writing the session files  on the server again.</p>
  
  <p>Well, I can suppress them. But is there a way of reopening a session, that has been closed with session_write_close without re-sending the Cookie-header? The Cookie-header is already sent correctly by the first session_start(). So the second one just needs to give me back access to writing to the session files stored on the web server.</p>
  
  <pre><code>&lt;?php
  session_start();
  // setting all the session vars I like to set
  session_write_close(); // &lt;-- // To allow parallel requests by the same user, while this script is still running
  
  // Code that takes some time to execute
  // It also prints output, so no more cookie headers after this point
  
  @session_start(); // &lt;-- works, but I like to use it without suppressing warnings
  $_SESSION['key'] = 'new value I like to store';
  session_write_close();
  ?&gt;
  </code></pre>