phpcodeigniterflash-message

Flash message show continuously in code-igniter


The flash message show continuously in open another page the we complete that event show that event message

Controller

$this->session->set_flashdata('msg', '<div class="alert alert-danger  text-center"> Some error occured... Try Later!!!...</div>');
redirect('Admin/add_customer');

View

<h4><?php echo $this->session->flashdata('msg');?></h4>

And we take another page after this event the same msg show in that page, refresh two or more time that will hide in new page , Any way to solve this issue ?


Solution

  • Normally flash-data will only be available for the next server request, and are then automatically cleared. so if you refresh the page and if its not cached, flash message should disappear.How ever if its not working, you could clear session data related to message in view (not encouraged)

    <h4><?php echo $this->session->flashdata('msg');
    unset($_SESSION['msg']);
    ?></h4>