php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26278 Can not user integer variable in $_SESSION
Submitted: 2003-11-16 20:01 UTC Modified: 2003-11-17 14:38 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: glumtail at yahoo dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.3.2 OS: FreeBSD
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: glumtail at yahoo dot com
New email:
PHP Version: OS:

 

 [2003-11-16 20:01 UTC] glumtail at yahoo dot com
Description:
------------
I found it can not save integer variable in session.
e.g:
  $_SESSION['TEST'] = 'SOMETHING'  // OK
  $_SESSION[1]      = 'SOMETHING'  // ERROR

My environment: FreeBSD + PHP 4.3.2
I think it must be a BIG bug.

Reproduce code:
---------------
<?php
session_start();
print_r($_SESSION); // always can not print $_SESSION[1]

$_SESSION[1]      = 'TEST';
$_SESSION['TEST'] = 'MY TEST';
print_r($_SESSION);
?>

Expected result:
----------------
Result (after refresh):
Array ( )
Array ( [1] => TEST [TEST] => MY TEST )


The correct result should be:
Array ( [1] => TEST [TEST] => MY TEST )
Array ( [1] => TEST [TEST] => MY TEST )


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-17 14:38 UTC] sniper@php.net
Of course you can't.

RTFM (http://www.php.net/session):

"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."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Dec 01 03:00:01 2025 UTC