php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38048 $_SESSION cannot be changed after copying it into another array
Submitted: 2006-07-09 15:03 UTC Modified: 2006-07-09 17:14 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: seitenzahl at hotmail dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.1.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: seitenzahl at hotmail dot com
New email:
PHP Version: OS:

 

 [2006-07-09 15:03 UTC] seitenzahl at hotmail dot com
Description:
------------
After doing something like 
$oldsessiondata = $_SESSION;
the changes to $_SESSION won't be committed to the session itself anymore.

I don't think $_SESSION should lose its magic properties in this case.

Reproduce code:
---------------
<?php
session_start();
$_SESSION['testbefore'] = 'foobefore';
print_r($_SESSION);
$oldsessiondata = $_SESSION;
print_r($_SESSION);
$_SESSION['test'] = 'foo';
print_r($_SESSION);
?>

Expected result:
----------------
Array
(
    [testbefore] => foobefore
)
Array
(
    [testbefore] => foobefore
)
Array
(
    [testbefore] => foobefore
    [test] => foo
)

After reload:
Array
(
    [testbefore] => foobefore
    [test] => foo
)
Array
(
    [testbefore] => foobefore
    [test] => foo
)
Array
(
    [testbefore] => foobefore
    [test] => foo
)

Actual result:
--------------
Array
(
    [testbefore] => foobefore
)
Array
(
    [testbefore] => foobefore
)
Array
(
    [testbefore] => foobefore
    [test] => foo
)

After reload:
Array
(
    [testbefore] => foobefore
)
Array
(
    [testbefore] => foobefore
)
Array
(
    [testbefore] => foobefore
    [test] => foo
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-09 15:25 UTC] seitenzahl at hotmail dot com
Fixed a typo in the summary.
 [2006-07-09 17:14 UTC] tony2001@php.net
See bug #37926.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 18:01:32 2025 UTC