CodeIgniter back button after logout

后端 未结 6 1153
攒了一身酷
攒了一身酷 2020-12-04 02:02

I\'m trying to stop/disable the back button functionality of the browser when a user logs out of my CodeIgniter (PHP) app. But, I think the browser is caching the page so it

6条回答
  •  孤街浪徒
    2020-12-04 02:51

    I think this could help you out, it works for me.

    CodeIgniter Framework version:

    $this->output->set_header('Last-Modified:'.gmdate('D, d M Y H:i:s').'GMT');
    $this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate');
    $this->output->set_header('Cache-Control: post-check=0, pre-check=0',false);
    $this->output->set_header('Pragma: no-cache');
    

    PHP version:

    header('Last-Modified:'.gmdate('D, d M Y H:i:s').'GMT');
    header('Cache-Control: no-store, no-cache, must-revalidate');
    header('Cache-Control: post-check=0, pre-check=0',false);
    header('Pragma: no-cache');
    

    if you are using PHP OOP put the above code in your constructor to initialize on your pages.

提交回复
热议问题