I am working with php sessions and user accounts. When they click on the Log Out link on a page it generates the code in logout.php which is...
<?
session_start();
session_destroy();
Header( “Location: http://www.espn.com” );
?>
The page destroys the session and for some reason it just goes back to the index.php page. I want to have it so that when the user is log out they are redirected to the page THEY WERE JUST ON logged out. I think I need to just change the code in my logout.php but I don't know what to do. I tried testing it by taking the user to espn.com but this didn't even work. Can someone help me set it up so that the user is sent to the page they were just on. Live Long and Prosper.
Header( “Location: http://www.espn.com” );
Should be
header("Location: http://www.espn.com"); //<--NOTE: You are using wrong quotes!
PS: Although php functions are case insensitive, but you'd better use the low case head
same with manual.
Update: If you want to redirect to the previous page, you could do:
if (!empty($_SERVER['HTTP_REFERER'])) {
header("Location: ".$_SERVER['HTTP_REFERER']);
} else {
header("Location: http://www.espn.com");
}
exit;