|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-02-16 21:29 UTC] goth at php-resource dot de
Hello, I've got a Problem unserializing variables which are a reference. An to me it seems to be a bug ... ! Example: session_start(); $_SESSION["A"]=10; $_SESSION["B"]=&$_SESSION["A"]; is correctly serialized to: A|i:10;B|R:1; I am happy ... ;) But if I call this session again ... maybe the next page PHP seems to loose the information that B was a reference. Example: session_start(); echo "BEFORE: A=".$_SESSION["A"]."<br />"; echo "BEFORE: B=".$_SESSION["B"]."<br />"; $_SESSION["A"]++; echo "AFTER: A=".$_SESSION["A"]."<br />"; echo "AFTER: B=".$_SESSION["B"]."<br />"; It results to: BEFORE: A=10 BEFORE: B=10 AFTER: A=11 AFTER: B=10 where I thought of A and B having the same value ... for B beeing a reference to A ... @sniper: Please don't answer ... your arrogant (and almost dumb) answers cause me one heart-attack after the other ... !!!!!! PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 11:00:01 2025 UTC |
Even as you think I'm arrogant and dumb, I'm marking this as verified. (In hope you really get a heart-attack..>:) Here's a complete test case script: <?php session_start(); if (isset($_GET['destroy'])) { session_destroy(); header("Location: {$_SERVER['PHP_SELF']}"); exit(); } echo "register_globals: ", ((ini_get('register_globals')) ? 'On' : 'Off'), "<br />"; if (!isset($_SESSION["A"]) && !isset($_SESSION["B"])) { $_SESSION["A"]=10; $_SESSION["B"]=&$_SESSION["A"]; } echo "BEFORE: A=".$_SESSION["A"]."<br />"; echo "BEFORE: B=".$_SESSION["B"]."<br />"; $_SESSION["A"]++; echo "AFTER: A=".$_SESSION["A"]."<br />"; echo "AFTER: B=".$_SESSION["B"]."<br />"; echo "<br /><a href='{$_SERVER['PHP_SELF']}?destroy=1'>destroy session</a> after changing register_globals setting to see the bug in effect"; echo "<br />(and reload the page couple of times..)"; ?> When register_globals = On -> Works. When register_globals = Off -> Does not work.