Session lost after refresh page! - 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 lost after refresh page! (/showthread.php?tid=76889) |
Session lost after refresh page! - macphisto - 06-30-2020 Hi, my problem with CI4 is that session not working after I refresh page. I load session in BasicController but it nothing change. Please help me. RE: Session lost after refresh page! - captain-sensible - 07-01-2020 i don't think anybody can help with this since there is not enough information to go on. Maybe you post your code your playing with in the controller , but as a starter ..in every controller involved in a session , my approach is to put session_start(); //at the start might not be the best approach but works for me public function credentials() { session_start(); RE: Session lost after refresh page! - truongict - 11-25-2020 (07-01-2020, 08:48 AM)captain-sensible Wrote: i don't think anybody can help with this since there is not enough information to go on.I have same mistake. In login Controller Quote:$this->session->set($data['user']); But after redirect, session is null. Thank you for your help!. RE: Session lost after refresh page! - Gary - 11-26-2020 In the 'receiving' controller, try inserting this somewhere at the top: Code: $this->session = \Config\Services::session(); RE: Session lost after refresh page! - InsiteFX - 11-26-2020 Or use the session helper it is changeable. PHP Code: $data = [ Either way you are not assigning a value to $data['user'] |