无法在Codeigniter中清除Flashdata [英] Flashdata not getting cleared in Codeigniter

查看:42
本文介绍了无法在Codeigniter中清除Flashdata的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Codeigniter 2.1.4,并且遇到了flashdata的一些问题。
成功提交记录后,我可以显示flashdata消息。但是,如果从显示flashdata消息的页面转到另一页,然后使用浏览器后退按钮返回上一页,则会再次向我显示flashdata消息。

如何清除一次flashdata消息
我认为不是flashdata发出了缓存问题。我很困惑为什么会这样。 如果它的缓存有问题,那么如何删除它?

I am using Codeigniter 2.1.4 and I have facing some issues with flashdata. When I successfully submit record I can display the flashdata message. But if go to the other page from the page where flashdata message was displayed and then go back to previous page using browser back button it shows me flashdata message again.
How to clear flashdata message once it used? I think its not the flashdata issue its cache problem. I am confused why this is happening. If its cache issue then how to remove it?

以下是我使用的代码,

//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;


推荐答案

您在控制器中的代码是正确的

your code in controller is right

//In the manage of controller
$this->session->set_flashdata('message', "Record updated successfully.");
redirect('controller_name/function_name','refresh');

现在可以像这样使用

if($this->session->flashdata('message')){echo $this->session->flashdata('message');}

希望它将起作用

这篇关于无法在Codeigniter中清除Flashdata的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆