php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34780 Serialize() and Sessions does not work properly
Submitted: 2005-10-07 16:02 UTC Modified: 2005-10-08 01:00 UTC
From: pavel_bogdanovic at yahoo dot de Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.0.5 OS: winxp
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: pavel_bogdanovic at yahoo dot de
New email:
PHP Version: OS:

 

 [2005-10-07 16:02 UTC] pavel_bogdanovic at yahoo dot de
Description:
------------
Situation: The session array key is the same like the var name. 

After serialize() the argument is also serialized.




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

$a[] = 'A';
$a[] = 'B';
$_SESSION['arr'] = $a;

echo '<pre>';
print_r($_SESSION['arr']);
$arr = serialize($_SESSION['arr']);
print_r($_SESSION['arr']);
echo '<br/>';
print_r($arr);
?>


Expected result:
----------------
Array
(
    [0] => A
    [1] => B
)
Array
(
    [0] => A
    [1] => B
)
a:2:{i:0;s:1:"A";i:1;s:1:"B";}

Actual result:
--------------
Array
(
    [0] => A
    [1] => B
)
a:2:{i:0;s:1:"A";i:1;s:1:"B";}
a:2:{i:0;s:1:"A";i:1;s:1:"B";}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-07 19:07 UTC] johannes@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

Check your register_globals setting. If on 
$_SESSION['arr'] and $arr refer to the same variable. 
 [2005-10-08 01:00 UTC] pavel_bogdanovic at yahoo dot de
wow, sorry for submitting no bug!
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 13:01:32 2025 UTC