I am using codeigniter4 and uses the following code
In the controller -
$this->session->setFlashdata('success','Your Data is saved');
return view('dashboard');
In the View
<?php if (session()->get('success')): ?>
<div class="alert alert-success" role="alert">
<?= session()->getFlashdata('success'); ?>
</div>
<?php endif; ?>
</div>
As per code igniter 4 , this flashdata should clear . But flashdata shows in the second page also . Then it clears on the third page .