Le 23/06/2021 à 15:31, Christoph M. Becker a écrit :
On 23.06.2021 at 15:18, Mathieu Dubois wrote:
Le 23/06/2021 à 14:37, Christoph M. Becker a écrit :
On 23.06.2021 at 13:41, Mathieu Dubois wrote:
Le 23/06/2021 à 12:01, Christoph M. Becker a écrit :
Before ::read() is called, open() is called. ::open() is suppossed to
create the empty session data, if no data for the given session exist.
This empty data string should then be returned from ::read(). If
::read() fails to read the data, it should return false (or actually
any
non-string value in the current implementation) to signal failure.
I might be confused but the session id is not passed to ::open() so how
is it supposed to create the empty session data ? By using session_id ?
Ah, right, ::open() is not supposed to create the empty session data.
This can be done in ::read(); the built-in "files" handler does this,
for instance; if the file does not exist and can't be created, ::read()
fails.
OK, that was the only explanation that made sense. Do we agree that the
doc could be improved by stating this more clearly ?
Yes. Consider to submit a pull request
(<https://github.com/php/doc-en/pulls>).
I can try but I'm not sure to understand enough.
By the way the doc for session-set-save-handler [1] does not mention
false for the read callback:
The read callback must always return a session encoded (serialized)
string, or an empty string if there is no data to read.
If I'm correct the protocol is the same in this case (i.e. read should
return a string or false).
Mathieu
[1] https://www.php.net/manual/en/function.session-set-save-handler.php
--
Mathieu Dubois - IR - UMR 8030 équipe LABGeM
CEA - Genoscope. 2 rue Gaston Crémieux. 91057 Evry Cedex France.
Bureau B07
+33 1 60 87 53 35