flash消息在打开另一页中连续显示我们完成该事件的事件消息
控制器
$this->session->set_flashdata('msg', '<div class="alert alert-danger text-center"> Some error occured... Try Later!!!...</div>');
redirect('Admin/add_customer');
查看
<h4><?php echo $this->session->flashdata('msg');?></h4>
,在此事件之后,我们在该页面中使用了另一个页面,在该页面中显示了相同的味精,刷新两个或多个时间,这些时间将隐藏在新页面中,有什么方法可以解决此问题?
通常仅适用于下一个服务器请求,然后自动清除。因此,如果您刷新页面且s not cached, flash message should disappear.How ever if it
s不起作用,则可以清除与视图中的消息有关的会话数据(不鼓励)
<h4><?php echo $this->session->flashdata('msg');
unset($_SESSION['msg']);
?></h4>
这是新版本的PHP中的一个问题。您可以通过更换系统/库中的420行/session/session.php:
来解决它。elseif ($value < $current_time)
elseif ($value === 'old' || $value < $current_time)
您可以尝试使用该类型的正常工作,我在所有CI项目中都使用了该代码。
控制器:
if($query){
$this->session->set_flashdata('success', 'Sucessful added store');
redirect($this->redirect);
}
else{
$this->session->set_flashdata('error', 'Something is wrong. Error!!');
redirect($this->redirect);
}
查看:
<?php if ($this->session->flashdata('success')) { ?>
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><?php echo $this->session->flashdata('success'); ?></strong>
</div>
<?php } ?>
<?php if ($this->session->flashdata('error')) { ?>
<div class="alert alert-danger">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><?php echo $this->session->flashdata('error'); ?></strong>
</div>
<?php } ?>
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><?php echo $this->session->flashdata('success'); ?></strong>
</div>
session-> flashdata('错误')){?> <div class="alert alert-danger">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><?php echo $this->session->flashdata('error'); ?></strong>
</div>