Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent back button after logout page

I Have php logout page. when user click in logout link See this page and redirect to index page. but when click in back button i see previouse page with user data. of course when i refresh page i dont see previouse page and data. i checked other code ( drupal ) after click logout and click back button i dont see previouse page and see login page. Where is my problem. how to fixed this ?

LOGOUT PAGE :

if (isset($_GET['req']) && $_GET['req'] == 'logout') {
      session_start();
      session_destroy();
      header("Location: index.php");
   exit();
}

Thanks

like image 289
BBKing Avatar asked Nov 05 '22 02:11

BBKing


1 Answers

The code is right. Actually you don't need to prevent people clicking on the back button. If you really think this is important you could save a cookie or something else in logout.php and the main page checks with AJAX whether this cookie is set. And if it is you could reload the page with JS (and of course unset the cookie then). But a really safe way doesn't exist.

like image 121
Dion Avatar answered Nov 07 '22 21:11

Dion