略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: SessionHandlerInterface::read

2024-11-14

SessionHandlerInterface::read

(PHP 5 >= 5.4.0, PHP 7, PHP 8)

SessionHandlerInterface::readRead session data

说明

public SessionHandlerInterface::read(string $id): string|false

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() If the record was not found, return false.

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().

参数

id

The session id.

返回值

Returns an encoded string of the read data. If nothing was read, it must return false. Note this value is returned internally to PHP for processing.

参见

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/sessionhandlerinterface.read.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3