user3094039
user3094039

Reputation: 11

Logout and browser back button

I am trying to log out from my session. The logout is successful but upon hitting the back button, I am taken back to the 'secret' page and I can access all the links etc ...

This is in of my 'secret' page:

if(isset($_COOKIE['ID_my_site'])) 

{ ........... }

else { header("Location: login.php"); } 

And my logout page is as follows:

unset($_COOKIE['ID_my_site']);
session_destroy();

$past = time() - 01; 

setcookie(ID_my_site, gone, $past); 
setcookie(Key_my_site, gone, $past); 

header("Location: login.php"); 

Upvotes: 0

Views: 292

Answers (2)

Manish Patel
Manish Patel

Reputation: 1957

 <script type="text/javascript">
 function doLogout() { 
     var backlen = history.length;
     history.go(-backlen);
      window.location.replace("index.html");
 }
 </script>
 <a data-role="none" href="#" onclick="doLogout"></a>

Upvotes: 1

Gopal Joshi
Gopal Joshi

Reputation: 2358

put code something like this...

if (check session is alive){

}
else{
    header("Location: login.php");
}

Upvotes: 0

Related Questions