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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 17:01:30 2024 UTC