![]() |
Can't get user id from session - 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: Can't get user id from session (/showthread.php?tid=79215) |
Can't get user id from session - bylka06 - 05-12-2021 Hello, so i'm trying to insert the user id to a table named "services", but it seems that session('id') isn't working, but when i'm tring to insert it in "images" table, it's working fine, can any one help me with that ? Link to my controller : https://pastebin.com/5dLDUQMc RE: Can't get user id from session - demyr - 05-13-2021 When I gave a look at your codes I could'nt see that you started a session first. When the user log in, a session should start first. Then you can call any information related to it. or, if your url contains an id, you can get it via : PHP Code: $id = $this->request->uri->getSegment(2); *2 can be 1 or 3. Depends on your url RE: Can't get user id from session - bylka06 - 05-13-2021 (05-13-2021, 09:29 AM)demyr Wrote: When I gave a look at your codes I could'nt see that you started a session first.Hello, thank you for your reply, si i started a session when the user logs in, in the "login" controller here the link to that : https://pastebin.com/1SXynPBF RE: Can't get user id from session - demyr - 05-13-2021 Hi again, Your codes don't look healthy. For example, you are trying to start your session with an email, not with a password match. And your password area doesn't have any encryption. I am leaving my codes below: PHP Code: public function login_process (){ Within your other methods in controller, just follow this : PHP Code: public function another_method(){ |