Reputation:
when a user logouts from my web site they are logged out but on the logout page there username and the log out link and profile link are still visible on the logout page but not on any other pages.
All I want to know is how do I change the logout page so that the log out and proflie links and username are not displayed like the rest of the pages.
I'm using the same file where the links and username are displayed for every web page so what is the problem with the logout page?
Please leave a code sample to solve this problem if possible?
Upvotes: 0
Views: 300
Reputation: 335
<?php
session_start();
$_SESSION = array();
session_unset();
session_destroy();
header('login.php')
?>
Maybe you can try my method
Upvotes: 1
Reputation: 10806
You can try things as per other answers ..
Or just create a logout.php .. which doesn't output anything so you just start the session, destroy all of the session or the required keys and then redirect the user to a logout_done.php which outputs, something like, You have been successfully logged out blah blah ..
Upvotes: 0
Reputation: 655239
If you’re using a session based authentication, make sure that you reset the $_SESSION
variable as session_destroy
does not do that. So:
session_destroy();
$_SESSION = array();
Upvotes: 4
Reputation: 7347
it sounds like you include the code that displays the logout and profile links before you actually do the processing to log the user out. try seeing if you can rearrange the execution of your code so the include comes after youve already logged the user out.
Upvotes: 1
Reputation: 625077
I can only guess that your logic goes something like:
I'm assuming that (1) will do things like display the right links and the username (if logged in). The point is that you're doing checks on being logged in before you log the user out. If so, just change the order:
But it's hard to say definitively because I'm guessing at your page structure.
Upvotes: 3