I want to close my php session while I'm doing some computations (and outputs) and don't need the session, so that other scripts can use the same session concurrently. Later on I need the session again and therefore want to resume it. But this fails in PHP 7.3.
In PHP 7.0 the following worked fine, but in PHP 7.3 I get an error session_start(): Cannot start session when headers already sent
:
Main session closed now...<br>
Warning: session_start(): Cannot start session when headers already sent
Main session resumed...<br>
Value: <br>
Code example:
session_start();
$main_id=session_id();
$_SESSION["value"] = "xxx: ".time();
session_write_close();
$_SESSION=array();
echo "Main session closed now...<br>\n";
flush();
// session_id($main_id);
session_start(array('use_cookies'=>false, 'cache_limiter'=>''));
echo "Main session resumed...<br>\n";
echo "Value: {$_SESSION["value"]}<br>\n";
flush();
Expected output:
Main session closed now...<br>
Main session resumed...<br>
Value: xxx: 1584991252<br>
Is this a bug and does somebody know a workaround?
\n";` then try and start a session. – AbraCadaver Mar 28 '20 at 14:56