I am having a logout.php page which successfully logs out the user destroying all the session variables. But when i use the Back button of the browser, I am still able to see the last page when the user was logged in.
How can i redirect a page to login page when a Back button from the browser is pressed, once the user has logged out?
Logout.php
<?php
session_start();
if (isset($_SESSION['username']))
{
ob_end_clean();
$_SESSION = array();
session_destroy();
header( 'Location: ../Index.php' ) ;
exit();
}
?>
Please tell me if there is a php function to redirect the back button press to login page !
Redirect back to login page when BACK button is pressed?
Moderator: General Moderators
Re: Redirect back to login page when BACK button is pressed?
I'm not sure if you have an issue here or not. Assuming your code works as intended, it's possible using the back button will still generate the same result. The client's browser will still retain history and cache--you have no control over deleting this, and as such some information will be stored on the client's computer regardless.
Although--and someone correct me if I'm wrong--I do believe you have some control over the caching of websites, although there's nothing to stop a browser from ignoring cache headers.
Although--and someone correct me if I'm wrong--I do believe you have some control over the caching of websites, although there's nothing to stop a browser from ignoring cache headers.
Re: Redirect back to login page when BACK button is pressed?
Is there no way the problem could be solved?
Re: Redirect back to login page when BACK button is pressed?
Because you've killed the session, whatever they do on the cached page won't have any effect if it requires them to be logged in, such as clicking on certain links. Thus there should be no security risk, and the fact that the user was previously logged in means they can theoretically be trusted with any information that might be on display on the previous page, given that they were previously logged in while viewing that page. But as Skara said, there isn't really anything you can do concerning the user's browser cache. It's an inconvenience, sure, but not really a big problem.