(05-21-2020, 02:57 AM)jim1001 Wrote: (11-04-2019, 09:35 AM)Gary Wrote: if I remember correctly, I believe I previously experienced the same problem of losing session data when using the redirect() command in my code... but manage to side-step the issue at the time by using other ways to call the new page (without using the redirect() command directly).
I too am using out-ofbox settings and session data could be picked up in other php files of my app until I started to use a redirect() when I found all session data was lost in the redirected page.
I read about alternative redirect way to side-step issue and tried the header('Location...) solution but that also didn't work. I'm using PHP 7.4.5 and CI4.
Any advice welcome - thanks.
Sorry... being a bit of a noob and, at best, a complete hack on the computer, my visits to this site are sporadic... often with long interludes. Not being an expert, I also don't bother subscribing to threads, because most of the time I don't have a lot to add.
At any rate, for those that end up on this page, searching for solutions in the future... quite a few things can cause the the session to get lost. Under the situation discussed in this thread, you could possibly try using < session_write_close(); > before you invoke header() or redirect().
The new versions of PHP close the session for writing more often than the earlier versions did... for example if < exit; > is used in the code... but I think there are still cases (like the two mentioned above) that it currently (may) not - which causes it to remain open and therefore blocked (essentially lost) for the new page one is redirecting to.