php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27078 Numeric Keys for session variables are lost
Submitted: 2004-01-28 14:30 UTC Modified: 2004-01-28 14:45 UTC
From: rob dot brenart at tradingtechnologies dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.3.4 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rob dot brenart at tradingtechnologies dot com
New email:
PHP Version: OS:

 

 [2004-01-28 14:30 UTC] rob dot brenart at tradingtechnologies dot com
Description:
------------
Perhaps it's intentional as variables aren't supposed to be numeric, but seeing as it's the $_SESSION array, I figured this would be allowed.  

Reproduce code:
---------------
<?php
session_start();

echo '<pre>';
print_r($_SESSION);
echo '<hr>';
$_SESSION[167]='hi world';
print_r($_SESSION);

echo '<a href="test1.php">Here ya go</a>';

?>

Expected result:
----------------
Array
(
    [167] => hi world
)Array
(
    [167] => hi world
)

Here ya go

Actual result:
--------------
Array
(
)
Array
(
    [167] => hi world
)

Here ya go

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-28 14:39 UTC] sniper@php.net
No, they're not allowed, RTFM:

"The keys in the $_SESSION associative array are subject to the same limitations as regular variable names in PHP, i.e. they cannot start with a number and must start with a letter or underscore. For more details see the section on variables in this manual."

 [2004-01-28 14:45 UTC] rob dot brenart at tradingtechnologies dot com
My mistake, I looked and missed it.  But then shouldn't this kick out a warning on the $_SESSION[167]='hi world'; line?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 13:01:27 2024 UTC