Adding Items to Session Data - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Adding Items to Session Data (/showthread.php?tid=56653) |
Adding Items to Session Data - El Forum - 01-09-2013 [eluser]surf66[/eluser] Hello... In my system, when a user logs in, their username is added into the session data. I would also like to run a query in order to retrieve their user_id from the database and add this into the session data as well. It is a pretty straight forward query and all usernames in the db are unique so every time I should be pulling out just one id from the db, there should be no problems there. Below is my login function where I am setting my session data. If anyone could help, all I want to do is grab the users id from db where it matches their username and set it in session data Thank you in advance Code: function login(){ Adding Items to Session Data - El Forum - 01-09-2013 [eluser]Eduard Stankovic[/eluser] You return data right after query... it means that code after return will not work Adding Items to Session Data - El Forum - 01-09-2013 [eluser]surf66[/eluser] Ahh ok thanks, but from that query, what I cant figure out is how to get the user_id and store it in a variable, do you know how? Adding Items to Session Data - El Forum - 01-09-2013 [eluser]Eduard Stankovic[/eluser] Code: function login(){ It should works .... i added some comments .. hope it helps Adding Items to Session Data - El Forum - 01-09-2013 [eluser]surf66[/eluser] Thanks for your help, I am currently away from a pc I will try this out tomorrow and report back Adding Items to Session Data - El Forum - 01-10-2013 [eluser]surf66[/eluser] Thanks for everyone's help, I now have a working solution ! Hopefully it will help others in the future too! |