php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40274 Sessions fail with numeric root keys
Submitted: 2007-01-29 13:40 UTC Modified: 2007-02-06 00:01 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: ben at vanilla dot net Assigned: iliaa (profile)
Status: Closed Package: Session related
PHP Version: 5.2.0 OS: FreeBSD 6.2
Private report: No CVE-ID: None
 [2007-01-29 13:40 UTC] ben at vanilla dot net
Description:
------------
If you set a session variable with the root key as a numeric 
string it fails to save. It also fails to save anything else 
in the array after the numeric rook key string.

This was via FCGI with lighttpd, but also reproduced on Debian 
etch with apache2.

Reproduce code:
---------------
Set a session :-

<?php
session_start();

$_SESSION['Test1'] = "This should be ok";
$_SESSION['123']['test']="This is a test";
$_SESSION['Test2'] = "This is not saved";
?>
<PRE>
Session Set:
<?php print_r($_SESSION); ?>
</PRE>

Read it :-

<?php
session_start();

?>
<PRE>
Session Read:
<?php print_r($_SESSION); ?>
</PRE>

Expected result:
----------------
I would expect to see the same details in the session from the 
second piece of code as output from the first. :-

Session Read:
Array
(
    [Test1] => This should be ok
    [123] => Array
        (
            [test] => This is a test
        )

    [Test2] => This is not saved
)

Actual result:
--------------
Session Read:
Array
(
    [Test1] => This should be ok
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-29 13:48 UTC] ben at vanilla dot net
Juts noticed this is the same with numeric strings and 
ordinary numeric keys.
 [2007-02-02 18:57 UTC] jhansen at unitedmcgill dot com
I had a similar issue on a gentoo box (I could not make changes to session variables), and came across this blog post: http://bloggingabout.net/blogs/ramon/archive/2006/10/27/Weird-php-session-behaviour.aspx

Sure enough, turning off register globals fixed the problem for me. iliaa: Could this be related?
 [2007-02-05 09:15 UTC] ben at vanilla dot net
register_globals is set to Off anyway in php.ini file so 
whilst it sounded like a good idea, its unfortunately not a 
fix for this issue.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC