php - codeigniter flashdata not clearing -
i'm newbie codeigniter , i'm creating project in users created , managed. here i'm using flashdata display temporary messages "user created",etc.,
my code set flash data is
$this->session->set_flashdata('message', 'user created.');
in view called
$this->session->flashdata('message');
my problem when user created,flashdata displayed , when click home link flash data still available when click refresh/home again disappears. want cleared when click home link first time itself. there way code it??.
flashdata available next server request, , automatically cleared.
if($user_created) { $this->session->set_flashdata('success', 'user created!'); redirect('login'); } else { redirect('register'); }
You need to use php version less than 7.4 or you can modify the following code to solve the problem-
ReplyDeleteRoot directory > system > libraries > Session > Session.php //Lines 418 to 423:
// Hacky, but 'old' will (implicitly) always be less than time() ;)
// DO NOT move this above the 'new' check!
elseif ($value === 'old' || $value < $current_time)
{
unset($_SESSION[$key], $_SESSION['__ci_vars'][$key]);
}