Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP's real SESSION object
    text
    copied!<p><strong>EDIT:</strong> (UPDATED)</p> <p>Maybe my question was not clear enough. Ok, lets put it this way:</p> <pre><code>$arr["a"] = 10; var_dump($arr); $arr["b"] =&amp; $arr["a"]; var_dump($arr); </code></pre> <p>the first var_dump returns:</p> <pre><code>array 'a' =&gt; int 10 </code></pre> <p>While the second one returns:</p> <pre><code>array 'a' =&gt; &amp;int 10 'b' =&gt; &amp;int 10 </code></pre> <p>If I <em>unset($arr["a"])</em> it will return:</p> <pre><code>array 'b' =&gt; int 10 </code></pre> <p>The rule is, when 2 or more variables "points" to the same content var_dump will display the reference with an ampersand character (&amp;). </p> <p>In the case of $_SESSION, even with <strong>register_long_arrays = Off</strong> $_SESSION still shows a reference. So it is obvious that other variable is also pointing to the same content.</p> <p>In other words, if I unset($_SESSION) there is still other variable somewhere that can be linked to. In the above example, when I <em>unset($arr["a"])</em> I can still recover that content if I create a link, something like: <strong>$arr["z"] =&amp; $arr["b"]</strong>. </p> <p>So, my original question was, does anyone know WHICH is that other variable? It is very probable that such variable do not exists... but I was wondering why inside PHP shows that reference.</p> <p>Thank you</p> <hr> <p>(Original question:)</p> <p>When you create a session in PHP, for example:</p> <pre><code>session_start(); $_SESSION["name"] = "my name"; </code></pre> <p>and dump the GLOBAL variables with:</p> <pre><code>var_dump($GLOBALS); </code></pre> <p>you will see something like:</p> <pre><code> 'HTTP_SESSION_VARS' =&gt; &amp; array 'name' =&gt; string 'my name' (length=7) '_SESSION' =&gt; &amp; array 'name' =&gt; string 'my name' (length=7) 'HTTP_SERVER_VARS' =&gt; array ... </code></pre> <p>As you can see, both variables $GLOBAL[HTTP_SESSION_VARS] and $_SESSION are references to other object's content... Do anyone knows which is that object?</p> <p>In theory, if I unset both variables, somehow It must be possible to access that content... any clue?</p> <p>Thank you!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload