![]() |
Flashdata not clearing on refresh/redirect - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Flashdata not clearing on refresh/redirect (/showthread.php?tid=78596) |
Flashdata not clearing on refresh/redirect - msheath - 02-12-2021 Using CI 3.1.11: I am sending a flashdata error message when a form is filled incorrectly. The message is appearing correctly but does not clear on refresh/redirect. Controller method includes: Code: $this->session->set_flashdata('message', '<div class="alert alert-danger">The fields Model, Actual, Photo, Drawing and Painting can only be either blank or contain X</div>'); The session array looks like this: Code: array (size=5) I have researched this extensively via Google but have seen nothing helpful. As a further note, I have changed flashdata to tempdata with an expiry time of 10sec and the same behaviour persists. I can read the error message but it does not expire and refreshing the screen does not get rid of the message. I have to log out and log in again to do that. RE: Flashdata not clearing on refresh/redirect - demyr - 02-12-2021 May I ask why you are keeping it within your array? RE: Flashdata not clearing on refresh/redirect - msheath - 02-12-2021 (02-12-2021, 07:50 AM)demyr Wrote: May I ask why you are keeping it within your array?I'm not doing that consciously - it just appears like that. How would I do it differently? RE: Flashdata not clearing on refresh/redirect - demyr - 02-12-2021 Well, in your controller: 1- get the data from your view (You can check the link I am leaving for step 2) 2 check if they pass your rules or not (Follow this link) 3- if yes, pass them to model. 4- if not, turn back an error (no need for flashdata). - - - - 3- If you pass your data to model and to database successfully then you can call your flashdata, like: PHP Code: $data = [ By the way, why don't you go with CI 4? RE: Flashdata not clearing on refresh/redirect - msheath - 02-12-2021 Well my existing controller method follows the same pattern: Code: public function log_illustration_update($id) RE: Flashdata not clearing on refresh/redirect - mskarn - 03-04-2021 (02-12-2021, 02:58 AM)msheath Wrote: Using CI 3.1.11: I have the same issue after upgrading from PHP 7.4 to PHP 8.0.2. RE: Flashdata not clearing on refresh/redirect - mskarn - 03-04-2021 Looks like this will be fixed in 3.1.12: https://github.com/bcit-ci/CodeIgniter/pull/6013 RE: Flashdata not clearing on refresh/redirect - Muzikant - 03-18-2021 I can confirm this bug in CodeIgniter 3.1.11. The flashdata are not cleared on PHP 8 and acts like normal session data. RE: Flashdata not clearing on refresh/redirect - Garnet - 09-30-2021 [quote pid="384357" dateline="1613123894"] You can use unset($_SESSION['some_name']); after calling session data on view [/quote] RE: Flashdata not clearing on refresh/redirect - InsiteFX - 10-03-2021 If your writing an application it is best to leave caching turned off while testing yurn it on when you need to test the caching. You can also use the new opcache in php which will speed up your app 10 fold. |