![]() |
Lost Session Data - 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: Lost Session Data (/showthread.php?tid=86746) |
Lost Session Data - 68thorby68 - 02-15-2023 Hi I'm using CI 4.2.12 and the latest Myth Auth (modified) for user login. My login script works OK and sets the session data as required. But when I redirect to another controller, all of the data in the session is removed. Please note I've inserted and provided some logging info, to try and show exactly what is happening, along with my config and scripts. Any help here is gratefully appreciated as I've spent hours trying to rectify this. Many thanks. Config/App setting PHP Code: public $sessionRegenerateDestroy = false; The relevant part of my login script PHP Code: log_message('notice', '[MYTH AUTH - session state after identifying user] {file}-{line}, '.print_r(session()->get(),true)); The first part of my redirected page PHP Code: <?php namespace App\Controllers; And here is the log Code: INFO - 2023-02-15 10:34:29 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver. RE: Lost Session Data - 68thorby68 - 02-16-2023 [UPDATE] It looks as though the last line in the login script is erasing the session data. IS THIS A KNOWN BUG? PHP Code: return redirect()->to($redirectURL); To work round this, I can included the session variables (that get erased), in the redirect url. PHP Code: $redirectURL = landing?logged_in=9&db_conn=c_1&db_prefix=de1 Then add these values to the session in the target controller. This seems to work OK for now, but I'm not sure of any security impliactions and whether this would be a recommended work around ? |