ConFoo Montreal 2017 Calling for Papers


(PHP 5 >= 5.4.0, PHP 7)

SessionHandlerInterface::writeWrite session data


abstract public bool SessionHandlerInterface::write ( string $session_id , string $session_data )

Writes the session data to the session storage. Called by session_write_close(), when session_register_shutdown() fails, or during a normal shutdown. Note: SessionHandlerInterface::close() is called immediately after this function.

PHP will call this method when the session is ready to be saved and closed. It encodes the session data from the $_SESSION superglobal to a serialized string and passes this along with the session ID to this method for storage. The serialization method used is specified in the session.serialize_handler setting.

Note this method is normally called by PHP after the output buffers have been closed unless explicitly called by session_write_close()



The session id.


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.

Valor Retornado

O valor retornado (geralmente TRUE no sucesso, FALSE em falha). Note que esse valor é retornado internamente ao PHP para processamento.

Veja Também

add a note add a note

User Contributed Notes 1 note

barkoczi dot roland at aercode dot com
1 year ago
Note: this function won't be called in case $session_data is unchanged. In order to call this function every time when session is about closing, add $_SESSION["timestamp"] = time();
To Top