![]() |
Session Problem in CI4 - 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 Problem in CI4 (/showthread.php?tid=86002) Pages:
1
2
|
Session Problem in CI4 - tareq - 12-30-2022 I am trying to setup a Project using CI4. My problem is I can not access Session Data through my Project. Below are my settings: \App\Config\App Settings are as below: Code: public $forceGlobalSecureRequests = true; \App\Controller\BaseController Settings are as below: Code: namespace App\Controllers; \App\Controllers\Login as below: Code: namespace App\Controllers; Also WRITEPATH.'session' folder is empty. Please help me to solve this issue. RE: Session Problem in CI4 - kenjis - 12-30-2022 The code seems no problem. Quote:var_dump($this->session); //There is no data. Also on Dashboard no Session data What do you mean by no data. What value exactly shows? RE: Session Problem in CI4 - ozornick - 12-30-2022 What? $request exists by default PHP Code: $this->request = \Config\Services::request(); RE: Session Problem in CI4 - tareq - 12-30-2022 (12-30-2022, 06:08 PM)kenjis Wrote: The code seems no problem. There is no data that I set using $this->session->set() command RE: Session Problem in CI4 - InsiteFX - 12-31-2022 Add this to the top of your BaseController. PHP Code: use CodeIgniter\Session\Session; RE: Session Problem in CI4 - tareq - 12-31-2022 (12-31-2022, 12:20 AM)InsiteFX Wrote: Add this to the top of your BaseController. Still did not work. RE: Session Problem in CI4 - kenjis - 12-31-2022 (12-30-2022, 10:15 PM)tareq Wrote: There is no data that I set using $this->session->set() command I cannot see your screen. Please show what you got. You are saying what you don't see, but it does not help a lot. One thing, you should check: PHP Code: var_dump($this->session->get('userid')); $this->session is a session object, and if you var_dump it, it does not contain any session data you set. RE: Session Problem in CI4 - tareq - 12-31-2022 (12-31-2022, 02:12 AM)kenjis Wrote:(12-30-2022, 10:15 PM)tareq Wrote: There is no data that I set using $this->session->set() command OK. I am explaining it. As you can see, I set userid variable using $this->session->set('userid', 1); Now on Dashboard I am using var_dump($this->session->get("userid")); which shows me NULL RE: Session Problem in CI4 - kenjis - 12-31-2022 What if you use dd($this->session->get("userid")) on Login controller? Does your web server PHP have permission to write in WRITEPATH.'session' folder? RE: Session Problem in CI4 - kenjis - 12-31-2022 Try Local Development Server. See https://codeigniter.com/user_guide/installation/running.html#local-development-server If your code works on it, the problem is in your server configuration. |