PDA

View Full Version : Logout Button



tomyknoker
08-29-2007, 10:57 AM
I have a logout button with that links to the following page which contains:


<?php
//log out//
unset($_SESSION['blnUserLoggedIn']);
//session_destroy();
header('Location: welcome.htm');
?>

But when you get re-directed back to the welcome page, the user is still logged in... Any ideas?

tech_support
08-29-2007, 11:02 AM
Have you called session_start() before session_destroy()?

tomyknoker
08-29-2007, 11:08 AM
Yea I call it on a page called top.php, then this has a logout button which links to logout.php which has the above... When the user clicks it redirects to another page called bottom.php... If I change the re-direct page to top.php, it's still logged in... When I remove the comments around session_destroy() I get the following:


Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in /home/logout.php on line 5

Warning: Cannot modify header information - headers already sent by (output started at /home/html/logout.php:5) in /homel/logout.php on line 6

tech_support
08-29-2007, 11:20 AM
Try calling:


session_start();
session_destroy();

on a separate file and see if it logs you out.

tomyknoker
08-29-2007, 11:25 AM
It just says now:


Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in /home/html/logout.php on line 5

Warning: Cannot modify header information - headers already sent by (output started at /home/html/logout.php:5) in /home/html/logout.php on line 6

tech_support
08-30-2007, 06:39 AM
Did you have any HTML code in that file? Just put <?php session_start(); session_destroy(); ?> and nothing else in that file.