0
votes

I am working on codeigniter and when user logout session is destroyed but when user press browser back button it take to the last visit page.

I use javascript:

window.history.forward();

but it cause effect after login pages too

this is PHP code

$this -> session -> sess_destroy();
        redirect(base_url());
1
You're not checking session on previous page, that's why user can see prev page after back button.Aksen P
nope because when i refresh page it take me to the login page if it is session problem it will take the user to other pages as wellhassan

1 Answers

0
votes

Back button is controlled in the client side and CodeIgniter cannot disable it. Whatever the page you are seeing on back button is from the browser cache. Easiest way to solve this is to use Cache Headers in the application response.

set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');

For the page that you are seeing on back button, add session check in onload() so that if session is already logged out it will redirect to login.