SessionHandlerInterface protocol

[email protected] (Mathieu Dubois)
Newsgroups php.general
Message-ID <[email protected]>
Dear list,

I'm trying to understand PHP session handlers and more precisely the 
return value of SessionHandlerInterface::read.

The doc [1] states (emphasis mine):

    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.

However, the example used in the documentation of the SessionHandler 
class [2] and other implementations (for instance Symfony's 
PdoSessionHandler [3]) seem to return an empty string when nothing can 
be read.

If I understand well, the first time you connect to an host, nothing can 
be read. My own test seems to indicate that returning false in this case 
triggers an error while returning an empty string creates a new session.

Can someone clarify this ? How is the value false used ? More generally, 
I haven't found a clear explanation of which method is called at which 
time during session creation and how the values are used.

Note that I have posted the same question on SO [4] but I'm not 
satisfied by the answers.

Thanks in advance,
Mathieu

   [1] https://www.php.net/manual/en/sessionhandlerinterface.read.php
   [2] https://www.php.net/manual/en/class.sessionhandler
   [3] 
https://github.com/symfony/symfony/blob/c71c8727cc665c9e9b56e299fcfcc0adfbf02bac/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php#L638
   [4] https://stackoverflow.com/questions/68025570

-- 
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.