Bug #73302 [Com]: Copy-On-Write on $_SESSION fails with session_decode
| From: | x dot huberty at thecodingmachine dot Com | Date: | Thu, 13 Oct 2016 13:37:54 +0000 |
| Subject: | Bug #73302 [Com]: Copy-On-Write on $_SESSION fails with session_decode | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204665@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73302&edit=1
ID: 73302
Comment by: x dot huberty at thecodingmachine dot Com
Reported by: d dot negrier at thecodingmachine dot com
Summary: Copy-On-Write on $_SESSION fails with session_decode
Status: Open
Type: Bug
Package: Session related
Operating System: Ubuntu
PHP Version: 7.1.0RC3
Block user comment: N
Private report: N
New Comment:
Description:
------------
Bug can seen here:
https://3v4l.org/tekjZ
We have the same behaviour when we copy a temp variable ($sessionCopy) in $_SESSION.
Previous Comments:
------------------------------------------------------------------------
[2016-10-12 13:53:58] d dot negrier at thecodingmachine dot com
Description:
------------
Bug can seen here:
https://3v4l.org/m1HQ3
It affects all versions starting with 7.0.
If I copy the $_SESSION variable in another variable ($sessionCopy) and then I call session_decode,
I do not expect $sessionCopy to be impacted by the call to $_SESSION.
Yet, in PHP 7.0+, $sessionCopy is also modified.
Test script:
---------------
<?php
session_start();
// $_SESSION is empty so $oldSession is empty too now.
// I expect copy to be by value, not by reference so anything impacting $_SESSION should not impace
$oldSession.
$oldSession = $_SESSION;
session_decode('id|i:1;');
var_dump($_SESSION);
var_dump($oldSession);
Expected result:
----------------
I expect $_SESSION and $oldSession to be different.
Actual result:
--------------
In PHP 7+, $_SESSION and $oldSession are equal.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73302&edit=1