<?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;
}
}
session_set_save_handler(new \DemoBugSessionHandler(), true);
session_start();
Deprecated: Return type of DemoBugSessionHandler::open($save_path, $name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/6S4XM on line 5
Deprecated: Return type of DemoBugSessionHandler::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/6S4XM on line 61
Deprecated: Return type of DemoBugSessionHandler::read($session_id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/6S4XM on line 21
Deprecated: Return type of DemoBugSessionHandler::write($session_id, $session_data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/6S4XM on line 46
Deprecated: Return type of DemoBugSessionHandler::destroy($session_id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/6S4XM on line 56
Deprecated: Return type of DemoBugSessionHandler::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/6S4XM on line 66
Warning: session_set_save_handler(): Session save handler cannot be changed after headers have already been sent in /in/6S4XM on line 72
Warning: session_start(): Session cannot be started after headers have already been sent in /in/6S4XM on line 74
Output for 8.0.0 - 8.0.30
Warning: session_id(): Session ID cannot be changed when a session is active in /in/6S4XM on line 24
Warning: session_start(): Session cache limiter cannot be sent after headers have already been sent (output started at /in/6S4XM:24) in /in/6S4XM on line 74
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: session_id(): Cannot change session id when session is active in /in/6S4XM on line 24
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/6S4XM:24) in /in/6S4XM on line 74