session is not working as I suspect it should
<p>I want to access a session in another page after I set it in a function. I can see that the session is set because I can echo it within the function. Then I send the user to another page where I want to access that session. The issue is that the session is empty when I am forwarded. Can someone tell me why this is?</p>

<pre><code>&lt;?php
session_start();

function test($val){
  session_destroy();

  if(isset($val)){
    $_SESSION['test'] = $val;
    echo $_SESSION['test']; // echos 'test'
    header("location: two.php");
  }
}

test('test');
?&gt;

&lt;?php
// two.php
session_start();

echo $_SESSION['test']; // errors undefined index 'test'
?&gt;
</code></pre>
