PHP :: Request #51127 :: $_SESSION illogical behaviour
| Request #51127 | $_SESSION illogical behaviour | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2010-02-23 18:56 UTC | Modified: | 2013-08-21 02:15 UTC |
|
||||||||||
| From: | asanoki at gmail dot com | Assigned: | yohgaki (profile) | |||||||||||
| Status: | Closed | Package: | Session related | |||||||||||
| PHP Version: | 5.2.12 | OS: | Linux | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2010-02-23 18:56 UTC] asanoki at gmail dot com
Description: ------------ No warning about using not allowed characters as a key in array $_SESSION. It is illogical, and should raise a warning or notice. In manual it is written that $_SESSION is a superglobal *associative array* (http://pl.php.net/manual/pl/reserved.variables.session.php). Additional restrictions to key names are illogical and unintuitive. Why do a session serialization function uses diffrent algorithm than default serialize() php function which works fine in such situations? Example. Using | character as a key in $_SESSION array causes damaging a session file (it gets 0 bytes length) without any notice, warning or error. I understand that it is mentioned in manual, but it is illogical, unintuitive and should raise at least a warning. Reproduce code: --------------- /* Here is php code which reproduces this error. Fire it *twice*, and look at output of a *second* execution. */ session_start(); echo "This was loaded from session:<br />\n"; var_dump($_SESSION); $_SESSION["a|b"] = "asdasd"; echo "<br />\nThis is written to session:<br />\n"; var_dump($_SESSION); Expected result: ---------------- This was loaded from session: array(1) { ["a|b"]=> string(6) "asdasd" } This is written to session: array(1) { ["a|b"]=> string(6) "asdasd" } Actual result: -------------- This was loaded from session: array(0) { } This is written to session: array(1) { ["a|b"]=> string(6) "asdasd" }
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2010-03-02 14:48 UTC] jani@php.net
-Summary: $_SESSION illogical behaviour. +Summary: $_SESSION illogical behaviour -Package: Feature/Change Request +Package: Session related
[2010-05-12 16:26 UTC] mike@php.net
-Status: Open +Status: Verified
[2011-02-03 13:09 UTC] cyberdisyan at gmail dot com
[2012-03-26 12:54 UTC] simon at hurix dot de
[2012-03-31 06:39 UTC] yohgaki@php.net
[2013-08-10 08:03 UTC] yohgaki@php.net