dongmei1911 2014-06-12 05:29
浏览 44
已采纳

CodeIgniter中的注销问题

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() {
        //pr($this->session->userdata[$this->section_name]);
        //exit;
        $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) {
            $this->SocialLogout($this->session->userdata[$this->section_name]['socialgateway']);
        }
        $this->session->unset_userdata($this->section_name);

        redirect(site_url($lng));
        exit;
    }
  • 写回答

3条回答 默认 最新

  • 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大