menelaus8888 Posted July 28, 2008 Share Posted July 28, 2008 hmmn. i am having a problem with my logout system on my thesis website wherein when i try to logout, the previous page can still be viewed when the back button is pressed even though all sessions are already destroyed. i've tried to put the following code at the top of the page that i dont want users to be viewed on back button: <? Header("Cache-control: private, no-cache"); Header("Expires: Mon, 26 Jun 1997 05:00:00 GMT"); Header("Pragma: no-cache"); header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT"); ?> and on the <head> <META http-equiv="expires" content="0"> ************************************* i found those codes which they say would clear the cache of the page. but still wont work. this is the top of my memberspage.php: <?session_start(); ?> <? // start session // if username blank, include login form. if (!$adminusername) { include 'loginpage.php'; exit(); } else { contents of my page } ?> code for my logout page: <? session_start(); session_unset(); session_destroy(); ob_end_clean(); header("Location: loginpage.php"); ?> when i try to login-->view memberspage-->refresh it--->logout-->then press back button--> it doesnt show the members page anymore but the login page. this is what i want to happen. is there any way to amend my codes like a redirect/refresh or something ? thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/116989-disable-viewing-previous-page-on-backbutton/ Share on other sites More sharing options...
samshel Posted July 28, 2008 Share Posted July 28, 2008 try putting an intermediate page logoutprocess.php..which destroys session and redirects to logout.php, on logout.php you can show message "Succesfully logged out" or whatever.. when user clicks back button, it will go to logoutprocess.php , which will redirect him back to logout.php this may fail in case use presses back 2 times..but i think that is stored in browser cache is difficult to erase..atleast i couldnt find anytihng Quote Link to comment https://forums.phpfreaks.com/topic/116989-disable-viewing-previous-page-on-backbutton/#findComment-601661 Share on other sites More sharing options...
menelaus8888 Posted July 28, 2008 Author Share Posted July 28, 2008 i tried this memberspage--->pressed logout--->viewed logout.php which has session_destroy, etc.. -->goes to logout2.php which has message of a successfull logout but when i pressed back button it still goes back to the members page. Quote Link to comment https://forums.phpfreaks.com/topic/116989-disable-viewing-previous-page-on-backbutton/#findComment-601695 Share on other sites More sharing options...
menelaus8888 Posted July 28, 2008 Author Share Posted July 28, 2008 voila. i just made a duplicate of members page. memberspage1 redirects to memberspage2 and it works. Quote Link to comment https://forums.phpfreaks.com/topic/116989-disable-viewing-previous-page-on-backbutton/#findComment-601714 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.