【问题标题】:CodeIgniter session issue after sign out browser back button landed to the secured page退出浏览器后退按钮登陆安全页面后的 CodeIgniter 会话问题
【发布时间】:2015-08-19 01:07:21
【问题描述】:

我在我的应用程序中使用codeIgniter 2.1.4。如果在需要身份验证的页面中。然后,如果我使用浏览器后退按钮,我会在注销后注销,它会让我回到安全页面。我只能查看页面。如果我刷新或点击任何链接,它会将我重定向到登录页面。

我认为这是缓存问题?但我不确定。

【问题讨论】:

标签: php codeigniter session browser-cache


【解决方案1】:

$this->output->nocache();粘贴到__construct()函数中parent::__construct();之后

【讨论】:

  • 你能解释一下为什么会有帮助吗?
【解决方案2】:

您可以通过添加来阻止客户端的浏览器缓存站点

<meta Http-Equiv="Cache-Control" Content="no-cache">
<meta Http-Equiv="Pragma" Content="no-cache">
<meta Http-Equiv="Expires" Content="0"> 

到您的 HTML 标头中。

【讨论】:

    【解决方案3】:

    在控制器的构造函数中包含这些头文件,以防止前一页的缓存

    如果您想要 Code Igniter 的操作方式,请包含以下代码

    $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 的实现方式使用以下代码行

    header("cache-Control: no-store, no-cache, must-revalidate");
    header("cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-26
      • 2012-12-22
      • 2023-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多