Sac*_*hin 5 php firefox google-chrome codeigniter
我正在使用 Codeigniter 2.1.4,但我在 flashdata 方面遇到了一些问题。当我成功提交记录时,我可以显示 flashdata 消息。但是如果从显示 flashdata 消息的页面转到另一个页面,然后使用浏览器后退按钮返回上一页,它会再次显示 flashdata 消息。
使用后如何清除 flashdata 消息?
我认为这不是 flashdata 问题的缓存问题。我很困惑为什么会发生这种情况。如果它的缓存问题那么如何删除它?
下面是我用过的代码,
//In the manage of controller
$this->session->set_flashdata('message', "Record updated successfully.");
// In the view of controller
$data['message'] = $this->session->flashdata('message');
// In the view page
echo $message;
Run Code Online (Sandbox Code Playgroud)
小智 9
这是工作:https://github.com/bcit-ci/CodeIgniter/pull/6013#issuecomment-1316482414
这是较新版本的 php 中的问题。您可以通过替换 system/libraries/Session/Session.php 中的第 420 行来修复它:
elseif ($value < $current_time)
Run Code Online (Sandbox Code Playgroud)
和
elseif ($value === 'old' || $value < $current_time)
Run Code Online (Sandbox Code Playgroud)
谢谢,
$this->session->set_flashdata('message', "Record updated successfully.");
Run Code Online (Sandbox Code Playgroud)