3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php header('X-foo: bar'); session_id('foobar'); var_dump(session_id()); session_write_close(); session_start(); session_id(''); var_dump(session_id()); ?>
based on OVbja
Output for 7.1.0 - 7.1.10
string(6) "foobar" Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /in/9GTWE:4) in /in/9GTWE on line 6 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/9GTWE:4) in /in/9GTWE on line 6 string(0) ""
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.0.24
string(6) "foobar" Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /in/9GTWE:4) in /in/9GTWE on line 6 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/9GTWE:4) in /in/9GTWE on line 6 string(0) "" Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0
Output for hhvm-3.18.5 - 3.22.0
string(6) "foobar" string(0) "" Warning: The session id contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct ()