Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeigniter flashdata not clearing

I'm a newbie to codeigniter and I'm creating a project in which users are created and managed. here I'm using flashdata to display the temporary messages like "user created",etc.,

My code to set flash data is

       $this->session->set_flashdata('message', 'User Created.'); 

In my view I called it as

$this->session->flashdata('message'); 

My problem is that when the user is created,flashdata is displayed and when i click home link the flash data is still available but when i click refresh/home again it disappears. I want it to be cleared when i click the home link for the first time itself. Is there a way to code it??.

like image 608
Pradeep G Avatar asked Dec 21 '22 00:12

Pradeep G


1 Answers

Flashdata will only be available for the next server request, and are then automatically cleared.

if($user_created)
{
    $this->session->set_flashdata('success', 'User created!');
    redirect('login');
}
else
{
    redirect('register');
}
like image 174
Wahyu Kristianto Avatar answered Jan 05 '23 17:01

Wahyu Kristianto