Codeigniter V 3.0 FlashData问题 [英] Codeigniter V 3.0 flashdata issue

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

问题描述

在codeigniter v3.0中,打印类似

In codeigniter v3.0 when printing message like

$ this-> session-> set_flashdata('message','XAdded Successed');

此处成功添加了成功写入div标签内并带有一些引导程序类以分配错误div的信息那么所有会话数据都会被自动销毁,并且在编写与

here added successfully written inside a div tag with some classes of bootstrap to assign error div then all the session data is destroyed automatically and when writing the same code as

$ this-> session-> set_flashdata('message','成功添加');

然后写一个简单的文本就可以了

then it is working fine when it is written a simple text

有人遇到相同的问题吗,请帮我建议解决的问题

is anyone facing the same problem problem please help me suggesting the issue to resolve it

推荐答案

Codeigniter Flash数据仅适用于重定向

Codeigniter flash data only works on redirect

将重定向和会话放置在需要重定向的地方.

Place redirect and session where need must have redirect though.

$this->session->set_flashdata('success', 'Success: You have added a new banner!');

redirect('admin/design/banners');

在视图上您可以重定向到

And on view could where you redirect to

<?php if ($this->session->flashdata('error')) { ?>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="alert alert-danger">
<?php echo $this->session->flashdata('error');?>
</div>
</div>
</div>
<?php } ?>
<?php if ($this->session->flashdata('success')) { ?>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="alert alert-info">
<?php echo $this->session->flashdata('success');?>
</div>
</div>
</div>
<?php } ?>

这篇关于Codeigniter V 3.0 FlashData问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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