Search code examples
phpsessionauthenticationsession-statesession-variables

PHP session error


I am using following session variables on 3 pages:-

On Login page,

$_SESSION['login']=1;

On Logout page,

unset($_SESSION['login']);

On Home page,

if(!isset($_SESSION['login']))
{
header("location: index.php");
exit();
 }

My homepage is not redirecting to the index.php after vising Logout page.


Solution

  • Did you call session_start() at the top of the Logout page?