d_unknown
d_unknown

Reputation: 875

How to deny user access when back in browser is clicked and user have already logout

I want to deny user access when user is not logged in. So, what I did is put this code in every function of my controller:

if((!$this->session->userdata('logged_in'))){
            redirect(site_url()."/Login/logged_in",'refresh');
} 

And I also have this one:

 public function logged_in(){
    $logged_in = $this->session->userdata('logged_in');

    if(!isset($logged_in) || $logged_in !== true){
       $this->load->view('ErrorAccess');
    }
}

Then when I tried to logout and click the back button in the browser, I actually can access the previous page that I have been into. How am I going to deny access for that situation?

Upvotes: 2

Views: 638

Answers (1)

d_unknown
d_unknown

Reputation: 875

putting this in the index.php of the codeigniter file:

header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");

credit to: Kevin Lee

PHP Codeigniter is showing the cache when i press the back button after I logout

Upvotes: 1

Related Questions