In the CodeIgniter 4, I am using Flashdata for displaying error or success messages in view page and I am using the below code:
<?php
if(session()->get("success")){
echo session()->get("success");
}
?>
It is not and as well as it redirect frequent in same page using this code!
CodePudding user response:
use Flashdata instead of session
.
Once you reload the page, flashdata will disappear
$session->setFlashdata('item', 'value');
# to rerive
$session->getFlashdata('item');
You can warp it with if
conditions well.
if($session->getFlashdata('item')){}
Read more Flashdata
- in codeigniter.com