php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37229 values of $_SESSION array in copyies are references
Submitted: 2006-04-27 22:33 UTC Modified: 2006-04-28 07:18 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: mcsimm at inbox dot ru Assigned:
Status: Closed Package: Session related
PHP Version: 4.4.2 OS: FreeBSD 5.4-RELEASE
Private report: No CVE-ID: None
 [2006-04-27 22:33 UTC] mcsimm at inbox dot ru
Description:
------------
When keeping copyies of $_SESSION array its values are copied as references.

Bug has found in version 4.4.2 (FreeBSD)
In version 4.3.10 (Windows) this work correctly.

Reproduce code:
---------------
<?php
session_start();
$test_array = array();

$_SESSION['var'] = 'first';
$copy1 = $_SESSION;

$_SESSION['var'] = 'second';
$copy2 = $_SESSION;

var_dump($copy1);
var_dump($copy2);
?>

Expected result:
----------------
array(1) {
  ["var"]=>
  string(5) "first"
}
array(1) {
  ["var"]=>
  string(6) "second"
}

Actual result:
--------------
array(1) {
  ["var"]=>
  &string(6) "second"
}
array(1) {
  ["var"]=>
  &string(6) "second"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-27 22:47 UTC] judas dot iscariote at gmail dot com
your test produces the "expected result" in current 5.2.0-dev CVS.
 [2006-04-28 00:43 UTC] bjori@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

Can't reproduce
 [2006-04-28 07:18 UTC] mcsimm at inbox dot ru
note: on 4.4.2 bug can be reproduced only on second request from browser, in other words when browser sends SID and appropriate session file exists and session_start() reads it.

I've tested it with the latest sources from your link -- in version 4.4.3-dev this bug is absent.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 04:01:28 2024 UTC