2014-06-12 05:29 阅读 33


I have a problem in logout with CI framework. When I logout & press backspace button then it will take me to logged in page.

I need to do refresh manually after logout to destroy session.

Please help me if anybody know.

Here is Code for Logout:

function logout() {
        $lng = (isset($this->session->userdata[$this->section_name]['site_lang_code']) && $this->session->userdata[$this->section_name]['site_lang_code'] != "") ? $this->session->userdata[$this->section_name]['site_lang_code'] : 'es';

        if (isset($this->session->userdata[$this->section_name]['social_login']) && $this->session->userdata[$this->section_name]['social_login'] == 1) {

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • 已采纳
    douzhang3822 douzhang3822 2014-06-12 05:35

    This has to be something with cache control meaning browser caching. I don't think redirect helps. you should disable this and use CodeIgniters Cache Library if any caching is needed.

    Add the following to the pages where users are required to be logged in:

    //Prevent browsers from using history to browse in the user system.
    $this->CI->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
    $this->CI->output->set_header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
    $this->CI->output->set_header("Pragma: no-cache"); 

    When pressing back in the browser the page will be refreshed.

    点赞 评论 复制链接分享
  • douhulao7642 douhulao7642 2014-06-12 05:33

    use redirect() to go to the main/home page after logout!

    redirect('mainController/index', 'refresh');
    点赞 评论 复制链接分享
  • douan3019 douan3019 2014-06-12 09:56
    点赞 评论 复制链接分享