Logout function in code igniter

I started using codeigniter for my project. I have a user authentication system for my site. I saw a video with nettuts to login. I am confused why logging out does not work properly.

I have the following exit function from my login controller.

function logout() { $this->session->sess_destroy(); redirect('main'); } 

If I click the Logout button, I will redirect the user to the main page. But after redirecting the user to the main page, if I click on the "Back" button in the browser, I will see the resignation and my name at the top of the page. I need help with where I'm wrong, or is there some important code missing from my controller.

Thanks in advance

EDIT

I think I found a solution. I have to add the following code to the appropriate controller

 $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0"); $this->output->set_header("Pragma: no-cache"); 
+2
php codeigniter logout
source share
2 answers

I think this is a problem with the browser cache. If you click back, you really see the cached page, as it was when you logged in.

Try pressing F5 when you immediately return to the page before exiting. Now it should show that you are logged out.

+3
source share

Adding a header to my main constructor solved my problem with IE7:

 $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0"); $this->output->set_header("Pragma: no-cache"); 
+3
source share

All Articles