title: php 7.3 can not open hidden session (session_id() fails to set id)
body: <p>I have a php application that opens a session and sends the appropriate cookie to the browser like normal.</p>
  
  <p>Somewhere in the script I want to close the current session, <strong>silently</strong> open a new one in the background, get some values from this "background session", close it again and resume the main session (the one the user got cookies for).</p>
  
  <p>In Debian Stretch having <strong>PHP 7.0</strong> the following minimal example worked like a charm but now in <strong>PHP 7.3</strong> (Debian Buster) I get several warnings and the example ceases to work.</p>
  
  <p>Expected output (as in PHP 7.0):</p>
  
  <pre><code>Main session closed now...&lt;br&gt;
  Read data '10' and closed hidden session again...&lt;br&gt;
  Main session resumed...&lt;br&gt;
  </code></pre>
  
  <p>Actual output (as in PHP 7.3):</p>
  
  <pre><code>Main session closed now...&lt;br&gt;
  Warning: session_id(): Cannot change session id when headers already sent
  Warning: session_start(): Cannot start session when headers already sent
  Read data '' and closed hidden session again...&lt;br&gt;
  Warning: session_id(): Cannot change session id when headers already sent
  Warning: session_start(): Cannot start session when headers already sent
  Main session resumed...&lt;br&gt;
  </code></pre>
  
  <p>Minimal (not-) working example:</p>
  
  <pre><code>$options=array('use_cookies'=&gt;false, 'cache_limiter'=&gt;'');
  session_start();
  $main_id=session_id();
  $_SESSION["value"] = "xxx";
  session_write_close();
  echo "Main session closed now...&lt;br&gt;\n";
  flush();
  
  session_id("IdOfHiddenSession");
  session_start($options);
  $count=$_SESSION['count']++;
  session_write_close();
  echo "Read data '$count' and closed hidden session again...&lt;br&gt;\n";
  flush();
  
  session_id($main_id);
  session_start($options);
  echo "Main session resumed...&lt;br&gt;\n";
  flush();
  </code></pre>
  
  <p><strong>How can I fix this?</strong></p>