3v4l.org

run code in 200+ php & hhvm versions
<?php class DemoBugSessionHandler implements SessionHandlerInterface { public function open($save_path, $name) { return true; } /** * Read session data * @link https://php.net/manual/en/sessionhandlerinterface.read.php * @param string $session_id The session id to read data for. * @return string <p> * Returns an encoded string of the read data. * If nothing was read, it must return an empty string. * Note this value is returned internally to PHP for processing. * </p> * @since 5.4.0 */ public function read($session_id) { // Simulate a session ID regeneration. \session_id('newsessionid'); return ''; } /** * Write session data * @link https://php.net/manual/en/sessionhandlerinterface.write.php * @param string $session_id The session id. * @param string $session_data <p> * The encoded session data. This data is the * result of the PHP internally encoding * the $_SESSION superglobal to a serialized * string and passing it as this parameter. * Please note sessions use an alternative serialization method. * </p> * @return bool <p> * The return value (usually TRUE on success, FALSE on failure). * Note this value is returned internally to PHP for processing. * </p> * @since 5.4.0 */ public function write($session_id, $session_data) { // Print back to the user agent the $session_id // that is going to be persisted when the script finishes. echo $session_id . PHP_EOL; return true; } public function destroy($session_id) { return true; } public function close() { return true; } public function gc($maxlifetime) { return true; } } ini_set('session.use_strict_mode', '1'); session_set_save_handler(new \DemoBugSessionHandler(), true); session_start(); echo ini_get('session.use_strict_mode') . PHP_EOL;
based on 7CKAl
Output for 7.3.0 - 7.3.1
Warning: session_id(): Cannot change session id when session is active in /in/pfKge on line 24 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/pfKge:24) in /in/pfKge on line 76 1
Output for 7.1.25 - 7.2.13
1 newsessionid