Unable to call WriteHandlerInterface method

So, I created a class that implements SessionhandlerInterface and set it as a session handler:

$sessionHandler = new SessionHandler();
session_set_save_handler($sessionHandler);
session_start();

The problem is that the write function is never called.

If I use the second parameter session_set_save_handler and set it to false:

session_set_save_handler($sessionHandler, false);

Then it works correctly. Can someone explain this behavior to me? I am using PHP 5.4.6.

The documentation says:

When using objects as session persistence handlers, it is important to register the shutdown function with PHP to avoid unexpected side effects from the way PHP internally destroys objects when shutting down and can interfere with recording and close the call. Normally you should register 'session_write_close' using the register_shutdown_function () function.

PHP 5.4.0, session_register_shutdown() "register shutdown" session_set_save_handler() OOP , SessionHandlerInterface.

.

+5
1

:

"write" , . , . , , .

, , echo.

+1

All Articles