I am printing session with print_r($_SESSION) in the index page it shows following array.
Array
(
[name] => hhh
)
index.php
<?php
session_start();
$_SESSION['name']='hhh';
I wanted to unset this variable whenever I want to. So I created a new php file in the same directory with the following contents
<?php
session_start();
echo "before destroying the session";
print_r($_SESSION);
unset($_SESSION['name']);//remove the name session variable which is available in my index page.
session_destroy(); //destroy the session
echo "after destroying the session";
print_r($_SESSION);
But whenever I run the above code it prints the following:
before destroying the sessionArray ( ) after destroying the sessionArray ( )
Why my session which is available in the index page is not accessible in the above script's page?.
Thanks in advance