$ this-> session-> set_flashdata()然后$ this-> session-> flashdata()不能在codeigniter [英] $this->session->set_flashdata() and then $this->session->flashdata() doesn't work in codeigniter

查看:210
本文介绍了$ this-> session-> set_flashdata()然后$ this-> session-> flashdata()不能在codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请查看以下代码:

  $ this-> session-> set_flashdata ,'这是一条消息'。 
var_dump($ this-> session-> flashdata('message'));

它返回 bool(false)。 / p>

我希望不会需要 redirect()




> venkat 的注释

编辑

  $ this-> session-> set_flashdata('message','This is a message。 
$ this-> session-> keep_flashdata('message');
var_dump($ this-> session-> flashdata('message'));

没有什么不同。

方案

很好,文档确实说明了


CodeIgniter支持flashdata或会话数据,只有
可用于下一个服务器请求,然后自动
清除。 p>

作为第一件事,这显然意味着你需要做一个新的服务器请求。
重定向,刷新,链接或其他意味着发送用户到下一个请求。



为什么使用flashdata如果你使用它在同样的请求,反正?你也不能使用flashdata或使用常规会话。


Please take a look at the following code:

$this->session->set_flashdata('message', 'This is a message.');
var_dump($this->session->flashdata('message'));

It returns bool(false).

I hope it doesn't NEED a redirect() to be recallable after that, because some times I need to call it right after setting the flashdata in a view.


Edit after venkat's comment

$this->session->set_flashdata('message', 'This is a message.');
$this->session->keep_flashdata('message');
var_dump($this->session->flashdata('message'));

No difference unfortunately.

解决方案

Well, the documentation does actually state that

CodeIgniter supports "flashdata", or session data that will only be available for the next server request, and are then automatically cleared.

as the very first thing, which obviusly means that you need to do a new server request. A redirect, a refresh, a link or some other mean to send the user to the next request.

Why use flashdata if you are using it in the same request, anyway? You'd might as well not use flashdata or use a regular session.

这篇关于$ this-> session-> set_flashdata()然后$ this-> session-> flashdata()不能在codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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