Re: Conflicting information in PHP documentation

From: Date: Sat, 28 Jan 2017 00:37:02 +0000
Subject: Re: Conflicting information in PHP documentation
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969386495@lists.php.net to get a copy of this message
Hi Steven, On Fri, Jan 27, 2017 at 2:25 PM, Steven George <steven@bx.com.au> wrote: > There is conflicting information in the PHP documentation. > > > > http://php.net/manual/en/session.customhandler.php states: > > > > *“…you may extend internal PHP handlers by inheriting from SessionHandler”* > > > > However, http://php.net/manual/en/class.sessionhandler.php > states: > > > > *“Warning … please implement the SessionHandlerInterface interface instead > of extending from SessionHandler.”* > > > > I’m not sure whether SessionHandler should be extended or not. > SessionHandler uses "previously used internal save handler" as its base class. This design may be used to extend session save handler for session data encryption/validation/serialization. However, if one would like to implement your own save handler object, inheriting "previously used internal save handler" method is useless. Therefore, users should use SessionHandler*Interface for it. BTW, session module is designed as modular. - "save handler" for save/retrieve session data - "serialize handler" for converting session data from/to $_SESSION Strictly speaking, "save handler" should only do save/retrieve session data from database and "serialize handler" should be used for data conversions including use defined encryption/validation/serialization. For historical reason, i.e. register globals, "serialize handler" was not exposed to userland. Register globals required specific serialization method which could be broken easily. I proposed userland serialize handler to remove SessionHandler workaround and to use proper modularization ( https://wiki.php.net/rfc/user_defined_session_serializer ), but 1st try was failed. For the time being, problematic SessionHandler base class may be used to do session data conversion if it is needed. Otherwise, users shouldn't use SessionHandler base class, but use SessionHandler*Interface. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.doc (#969386495) next »