跳转到主要内容

read

SessionHandlerInterface::read

Read session data

ENTITY

public

string

false

SessionHandlerInterface::read

string

id

Reads the session data from the session storage, and returns the results. Called right after the session starts or when session_start is called. Please note that before this method is called SessionHandlerInterface::open is invoked.

This method is called by PHP itself when the session is started. This method should retrieve the session data from storage by the session ID provided. The string returned by this method must be in the same serialized format as when originally passed to the SessionHandlerInterface::write. Return an empty string when no data is stored for the given session ID; return ENTITY only to report a failure.

The data returned by this method will be decoded internally by PHP using the unserialization method specified in session.serialize_handler. The resulting data will be used to populate the $_SESSION superglobal.

Note that the serialization scheme is not the same as unserialize and can be accessed by session_decode.

ENTITY

id
The session id.

ENTITY

Returns an encoded string of the read data, or an empty string if no data is stored for the session ID. Returning ENTITY reports a failure: session_start then emits an E_WARNING and returns ENTITY. Note this value is returned internally to PHP for processing.

ENTITY

The session.serialize_handler configuration directive.