session is not working as I suspect it should

e_pitt03

New Member
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?\[code\]<?phpsession_start();function test($val){ session_destroy(); if(isset($val)){ $_SESSION['test'] = $val; echo $_SESSION['test']; // echos 'test' header("location: two.php"); }}test('test');?><?php// two.phpsession_start();echo $_SESSION['test']; // errors undefined index 'test'?>\[/code\]
 
Back
Top