0

Im having trouble ending sessions for some reason :|

Heres my code. Can anyone see what the problem is?

<?php
include('includes/config.php');
unset($_SESSION['isLogged']);
session_destroy();
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>
   <head>
      
   </HEAD>
   <BODY>
<?php
echo '<div class="nav">'.$navigation.'</div>';
?>
You have been logged out. 
</body>
</html>
3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by nav33n
0

Try the following to destroy the session:

<?php
session_start()
include('includes/config.php');
$_SESSION = array();
if (isset($_COOKIE[session_name()])) {
    setcookie(session_name(), '', time()-42000, '/');
}
session_destroy();
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>
   <head>
      
   </HEAD>
   <BODY>
<?php
echo '<div class="nav">'.$navigation.'</div>';
?>
You have been logged out. 
</body>
</html>
0

Thanks for that. I didnt know you had to use sesssion_start() when ending a session.

1

In every page you use session variables, you should have session_start(). :)

Votes + Comments
Thanks :)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.