[英]Codeigniter flashdata issue
Codeigniter flash data issue I am not getting session flashdata value. Codeigniter Flash数据问题我没有获取会话FlashData值。 I checked the session there flash data is created as old.
我检查了会话,那里的闪存数据已创建为旧数据。 Why this happens and how can i correct the issue.
为什么会发生这种情况,以及如何解决该问题。
my sessiona: 我的sessiona:
3:{s:9:"user_data";s:0:"";s:11:"cp";s:5:"l";s:14:"flash:old:fvalue";s:32:"41f66604a0bec1c089d84023d3708d1d";}.
here flash data is marked as old. 此处闪存数据被标记为旧数据。 i created flash data in view this is my code
$this->session->set_flashdata('fvalue', '41f66604a0bec1c089d84023d3708d1d');
我创建了闪存数据,因为这是我的代码
$this->session->set_flashdata('fvalue', '41f66604a0bec1c089d84023d3708d1d');
To add flashdata: 要添加闪存数据:
$this->session->set_flashdata('stack', 'overflow');
You can use on view with this code: 您可以在View上使用以下代码:
$this->session->flashdata('stack');
Be sure your web page shouldn't redirect one more times. 确保您的网页不应再重定向一次。 If your redirection counts is more than one, you need to use:
如果重定向计数不止一个,则需要使用:
$this->session->keep_flashdata('stack');
To use Session class, In config/autoload.php
要使用Session类,请在
config/autoload.php
$autoload['libraries'] = array('session');
Setting Flash data 设置闪存数据
$this->session->set_flashdata('item', 'value');//$this->session->set_flashdata('name', 'Rakesh');
after set flash data redirect to method using 设置Flash数据后,重定向到使用的方法
redirect('controller/method_name');
Then in view (to show/this will execute when name
is set only) 然后在视图中显示(仅在设置
name
时显示/执行)
<?php
if($this->session->flashdata('name') != '')
{
?>
<div class="success">
<?php $this->session->flashdata('name'); ?>
</div>
<?php
}
?>
To Destroy Session 销毁会话
$this->session->sess_destroy();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.