Re: session_start() should not reset $_SESSIOn if it's not empty
| From: | Rowan Collins | Date: | Fri, 28 Jul 2017 12:48:48 +0000 |
| Subject: | Re: session_start() should not reset $_SESSIOn if it's not empty | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-100080@lists.php.net to get a copy of this message | ||
On 27 July 2017 18:03:23 BST, "lists@rhsoft.net" <lists@rhsoft.net> wrote:
>if that could work in the way that session_start() keeps the current
>state of $_SESSION if not empty it would be possible to put the
>APCU-Read and if exit($apcu_content); before session_start() which
>would
>gain another 30% performance
I think that behaviour would confuse more people than it would help. If anything, it should be an
error to access $_ SESSION if no session is currently open - if there is no session, the array has
no meaning. (Arguably, all the other superglobals should be read only for the same reason, but that
would be a huge break now.)
If I understand you right, the scenario you describe is "I don't want to start a session
yet, but if and when I do, I want to put this data into it". It feels like that could be
adequately handled in userland with a wrapper object (or global var and functions if you prefer),
which reads to and from $_SESSION when a session is open, but a a holding array when it's not
yet.
Regards,
--
Rowan Collins
[IMSoP]