codeigniter

session set flashdata

How to Set session flash data in controller

You can set flash data in controller just using this syntax

$this->session->set_flashdata('message', 'Message you want to set');

Here ‘message’ is identifier for access data in view. You can Set more than one message by just changing identifier.

for ex

$this->session->set_flashdata('my_alert', 'Message you want to set');
$this->session->set_flashdata('my_warnig', 'Message you want to set');

How to Display Flashdata in view

You can simply access the fashdata in view like this

<?php echo $this->session->flashdata('message'); ?>

For access multiple message just change identifier

For Ex.

<?php echo $this->session->flashdata('my_alert'); ?>
<?php echo $this->session->flashdata('my_warnig'); ?>

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow