How to use $_SESSION[] array elements among multiple pages of same website? And when/how to destroy them?
Error:
Variable undefined..
If you have a better suggestion, please help me out.
Code for action.php
<?php
include 'someheader.php';
session_start();
if(isset($_POST['submit'])
{
$_SESSION['name']=$_POST['name'];
//Some Codes Here
}
include 'footer.php';
?>
Other php file in same directory
<?php
if(isset($_SESSION['name']))
{
echo "Hi $_SESSION['name'].\n";
echo "You have been logged in.";
}
?>