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>

Recommended Answers

All 4 Replies

Do you get any error ? And, you don't have session_start(); in this script :-/

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>

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

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

commented: Thanks :) +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.