php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41854 Bug when php try to serialize a array with a number for key
Submitted: 2007-06-29 17:36 UTC Modified: 2007-07-04 22:41 UTC
From: leonardo dot celis at ohstudio dot com dot ar Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.2.3 OS: Windows XP
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: leonardo dot celis at ohstudio dot com dot ar
New email:
PHP Version: OS:

 

 [2007-06-29 17:36 UTC] leonardo dot celis at ohstudio dot com dot ar
Description:
------------
start.php: here the value is serialize, but php take the value from memory and show it.

show.php: here the value is take from the session file and try to unserialize. The session file have 0 bytes. Therefor the value is no show.

However this script works:
<?
$var['1'] = "Hola mundo";
$x = unserialize(serialize($var));
echo serialize($var) . "<br>";
print_r($x);
?>

This bug I've founded with my partner Mario Garc?a.




Reproduce code:
---------------
start.php
<?
session_start();
$_SESSION['1'] = "Hola mundo";
print_r($_SESSION);
?>

show.php
<?
session_start();
print_r($_SESSION);
?>

Expected result:
----------------
Array ( [1] => Hola mundo )

Actual result:
--------------
Array (  )

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-02 15:57 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The $_SESSION super-global cannot contain keys that are entirely numeric 
because it causes problems for register globals when every key becomes a 
variable and PHP does not allow entirely numeric variable names.
 [2007-07-04 22:37 UTC] leonardo dot celis at ohstudio dot com dot ar
Hi!

I've a question about the reply.

Why if a array with a numeric key is serialize, when it's deserialize works!

$var['1'] = "Hola mundo";
$x = unserialize(serialize($var));
echo serialize($var) . "<br>";
print_r($x);

But in $_SESSION doesnt?

Thanks!
 [2007-07-04 22:41 UTC] leonardo dot celis at ohstudio dot com dot ar
Another question,

When this script is execute works fine...

start.php
<?
session_start();
$_SESSION['1'] = "Hola mundo";
print_r($_SESSION);
?>

So, in this instance, the register global works fine. But when php try to retrieve the value from the tmp file, doesn't works?

Thanks again!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 02 00:01:30 2024 UTC