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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 00:01:32 2024 UTC