![]() |
Session data lost on redirect - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Session data lost on redirect (/showthread.php?tid=77381) |
Session data lost on redirect - Jan Zelenka - 08-24-2020 Hi, I'm struggling to to properly redirect from a filter. I'm trying to store some data in the SESSION before returning from the filter with the idea to use the data in the page redirected to. Everything works fine when I use secure connection (https). Without a secure connection the data written to teh SESSION is gone when I try to read it on the redirection target page. These are my coockie and session settings: PHP Code: public $sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler'; Any help is much appreciated. RE: Session data lost on redirect - Chroma - 08-27-2020 I don't know if this is of any help, but I have seen that often, if a cookie is set under HTTP, then it cannot be accessed under HTTPS, regardless of the flags you set for security etc. I am not sure why this is, but that's what I have seen. RE: Session data lost on redirect - Jan Zelenka - 08-27-2020 Thanks for your reply. It did help in the sense that I took a deeper look at things and realized that when using HTTPS, the $_COOKIES array is nicely populated and contains the session cookie while with HTTP there this array has no members. Anyone an idea why this would be the case? So, the answer in the first reply to my question actually did help. There was a secure session cookie stored in the browser from the time when I tested with HTTPS. Once I deleted this cookie from the browser, my site started to work on HTTP. Case closed and thanks one more time! RE: Session data lost on redirect - Chroma - 08-27-2020 I am glad that it is now working and that you have found a solution. ![]() RE: Session data lost on redirect - tgix - 08-27-2020 (08-27-2020, 05:35 AM)Jan Zelenka Wrote: Thanks for your reply. Have you checked the console of the browser for any messages? Could be related to SameSite setting on the cookie. |