3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Test implements SessionHandlerInterface { public function close() { echo 'closing' . PHP_EOL; return true; } public function destroy($session_id) { return true; } public function gc($maxlifetime) { return true; } public function open($save_path, $session_name) { return true; } public function read($session_id) { return 'testtest|s:7:"testing";'; } public function write($session_id, $session_data) { echo 'writing' . PHP_EOL; $status = session_status(); if ($status === PHP_SESSION_NONE) { echo 'session is closed' . PHP_EOL; } elseif ($status === PHP_SESSION_ACTIVE) { echo 'session is active' . PHP_EOL; } else { echo 'what happened'; } return true; } } $test = new Test(); session_set_save_handler($test, true); session_start(); session_write_close(); echo 'none: '; var_dump(PHP_SESSION_NONE ); echo 'active: '; var_dump(PHP_SESSION_ACTIVE );
based on ha3bd
Output for 7.1.0 - 7.2.6
writing session is active closing none: int(1) active: int(2)
Output for 5.6.4 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.0.20
writing session is closed closing none: int(1) active: int(2)
Output for 5.6.0 - 5.6.3
closing none: int(1) active: int(2)