Session variable won't echo if cleared on same page?
<p>I am having a strange issue of a session variable being empty when I clear it on the same page that I attempt to echo it. Here is a quick type-up of what I am trying to do.</p>

<p>Take this example;</p>

<p><strong>Page A:</strong></p>

<pre><code>$_SESSION['referer'] = 'abc123';
header('Location: http://www.test.com/pageb.php');
exit();
</code></pre>

<p><strong>Page B:</strong></p>

<pre><code>function get_referer() {

    $referer = '';
    if (isset($_SESSION['referer'])) {
        $referer = $_SESSION['referer'];
        $_SESSION['referer'] = null;
        unset($_SESSION['referer']);
    }
    echo $referer;
}
</code></pre>

<p>Now when I do this on page B with the functions...</p>

<p>If I run it all by itself it works:</p>

<pre><code>   get_referer();
</code></pre>

<p>When I run the echo inside the value attribute of the input (making sure to only run the function once on the page due to it being erased after being called), it didn't echo anything when I view source the page.</p>

<pre><code>&lt;input type="hidden" name="referer" value="&lt;?php get_referer(); ?&gt;" /&gt;
</code></pre>

<p>However, funny enough, if I make the input type="text" it works fine.</p>

<pre><code>&lt;input type="text" name="referer" value="&lt;?php get_referer(); ?&gt;" /&gt;
</code></pre>

<p>The issue only occurs on the value attribute for input type="hidden"</p>
