evilmind
evilmind

Reputation: 116

Codeigniter V 3.0 flashdata issue

In codeigniter v3.0 when printing message like

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

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', 'Added Successfully');

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

Upvotes: 0

Views: 1433

Answers (1)

user4412623
user4412623

Reputation:

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 } ?>

Upvotes: 2

Related Questions