ikbal
ikbal

Reputation: 11

Session logout not working

 session_start();  
 ob_start();   
 unset($_SESSION);  
 session_destroy();  
 header("Location:login.php");  

Even after logout from home page session didn't destroy inner pages redirection is working after logout. please help me

Upvotes: 0

Views: 553

Answers (2)

Kailas Patil
Kailas Patil

Reputation: 1

You should use session_unset instead of unset($_SESSION):

<?php
session_start();
session_unset();
session_destory();
header("Location:login.php"); 
?>

Upvotes: 0

www.data-blogger.com
www.data-blogger.com

Reputation: 4164

Make sure to only do a session_destroy right after you do session_start. Do not unset the whole variable, this also disables the registration of session variables.

 session_start();
 ..
 session_destroy();  
 header("Location: login.php");  

Upvotes: 1

Related Questions