Re: Cannot make use_strict_mode work with custom session handler upon 'files'
| From: | Aziz Saleh | Date: | Sat, 18 Mar 2017 14:30:16 +0000 |
| Subject: | Re: Cannot make use_strict_mode work with custom session handler upon 'files' | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-326022@lists.php.net to get a copy of this message | ||
On Fri, Mar 17, 2017 at 3:52 PM, Ivan Grigoriev <greedy.ivan@gmail.com>
wrote:
> I want to implement custom session handler upon internal files handler
> similar to this: http://php.net/manual/en/class
> .sessionhandler.php#example-5380 (example 1).
>
> But with session.use_strict_mode = 1.
>
> I have been trying to test this sample code, but I can't seem to get it to
> work:
>
> ---
> session_module_name('files');
> ini_set('session.use_strict_mode', '1');
>
> class MySessionHandler extends SessionHandler{}
> session_set_save_handler(new MySessionHandler(), true);
>
> session_start();
> var_dump(session_id());
> ---
>
> After delete an existing session file and rerun script, it create new file
> with the same id.
>
> When there is no session_set_save_handler() it works as expected: new file
> is created with new id.
>
> I suppose that it is a bug, but maybe there is a solution that I can't see.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
On the documentation page it says: "*SessionHandler* is a special class
that can be used to expose the current internal PHP session save handler by
inheritance."
There is also a big warning box that says: "*Warning**: *This class is
designed to expose the current internal PHP session save handler, if you
want to write your own custom save handlers, please implement the
SessionHandlerInterface
<http://php.net/manual/en/class.sessionhandlerinterface.php>
interface
instead of extending from *SessionHandler*."
http://php.net/manual/en/class.sessionhandlerinterface.php
Is what you are looking for.