Welcome Guest, Not a member yet? Register   Sign In
Session Flashdata Persisting Like Normal Session Data
#1

(This post was last modified: 09-28-2023, 05:41 AM by ltarrant.)

Hi,
I currently have an issue with Flashdata persisting and behaving like normal session data.
This occurs with direct use of Flash data like:
Code:
$session->setFlashdata('item', 'value');
As well HTTP response functions like:
Code:
return redirect()->back()->with('foo', 'message');

I am currently using PHP 8.1 and the DatabaseHandler Driver.

This has been working fine but I recently upgraded to from CI version 4.3.6 to 4.4.0.

I only just spotted this issue an assume its linked to the version change. More likely an error on my part manually changing bits as part of the upgrade or maybe missing something.

Has anyone else had any issues or can direct me to particular area of the upgrade changes I should look at more closely that might cause this issue?
Reply
#2

(09-28-2023, 05:41 AM)ltarrant Wrote: Hi,
I currently have an issue with Flashdata persisting and behaving like normal session data.
This occurs with direct use of Flash data like:
Code:
$session->setFlashdata('item', 'value');
As well HTTP response functions like:
Code:
return redirect()->back()->with('foo', 'message');

I am currently using PHP 8.1 and the DatabaseHandler Driver.

This has been working fine but I recently upgraded to from CI version 4.3.6 to 4.4.0.

I only just spotted this issue an assume its linked to the version change. More likely an error on my part manually changing bits as part of the upgrade or maybe missing something.

Has anyone else had any issues or can direct me to particular area of the upgrade changes I should look at more closely that might cause this issue?
For me, the behavior is the reverse; following a redirection back, flash data is not retained. I'm using regular session variables and then delete session data as soon as I'm done with it. 
Without more information, I believe it will be challenging to identify the source of your problem. 
Have you verified that the associated session variable is designated as flash data? Have you attempted to issue the command "$session->markAsFlashdata('item');" already?
 already?
Reply
#3

(This post was last modified: 09-28-2023, 08:19 AM by captain-sensible. Edit Reason: spelling )

I have a Blog form that sends data to a blog controller, it does some checking and if there an issue sends back info
in my controller if on one logic test there is a failure in my controller I have :

Code:
    $session = \Config\Services::session();
       $session->setFlashdata('info', 'Hello that is not an image file ');
                                 return redirect()->route('newblog');

the route newblog resuts in a view being rendered . IN the view there is :

Code:
     <h1 style ="color:red";>  <?php echo session()->getFlashdata('info'); ?></h1>

thats on 4.3.6 mind you . Maybe i will update and see if i get your problem
CMS CI4     I use Arch Linux by the way 

Reply
#4

var_dump(session()) after redirect?
Reply
#5

Got there in the end.

I tried to switch back to using the File Handler rather than Database Handler session driver to see if that helped. However, I then started getting an error message from CI framework about setting ini as the session was already started.

After much wasted time in transpires that another library that I was loading via composer (also recently added) was starting the session in its autoloader and messing with sessions. Removed this library and now all is well again.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB