How to disable back button in browser using javascript or any script

Posted by user225269 on Stack Overflow See other posts from Stack Overflow or by user225269
Published on 2010-04-14T03:03:47Z Indexed on 2010/04/14 3:13 UTC
Read the original article Hit count: 237

Filed under:
|

Im using wamp server for my php scripts. And Im having difficulties on the logout code. Every time I click on the logout link and then click on the back button on web browser it still shows the page which can only be access by the user who is logged in. I have this code at the beginning of the index.php which is called by the log out link to destroy the session:

<?php
session_start();
session_destroy();


?>

And I have this at the beginning of the user page:

<? 
session_start();
if(!session_is_registered(myusername)){
header("location:login.php");
}
?>

I don't know why the userpage can still be access after the user has logged out. So I'm thinking of disabling the back button when the user has logged out. Please help.

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript