![]() |
CodeIgniters session library - how to? - 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: CodeIgniters session library - how to? (/showthread.php?tid=7523) |
CodeIgniters session library - how to? - El Forum - 04-13-2008 [eluser]v33s[/eluser] Hello all, I am new in CodeIgniter and I have a question about CodeIgniters Sessions. Can someone explain me how to start write simple admin login page area? I tried most of complete Authorization Systems but I don`t understand how to implement them in my code. Ok. I have my `admins` MySQL table with -id-name-md5password- columns. On first place in my Contructor, i have that code: Code: $this->load->library(array('session', 'validation')); I would like to check the form values with the database values, if it is correct then make a session. I can extract user from database, but how to make a session, check it if admin is now logged in??? I found in User Guide how to make a session: Code: $newdata = array( And now, what I must change in this array? Replace username with this from database? How to check this session if it is correct? Sorry for my English ![]() CodeIgniters session library - how to? - El Forum - 04-13-2008 [eluser]Seppo[/eluser] Well... to login you have to store something on the session... you don't have an email, so, with your db columns you can do Code: $this->db->where('username', $this->input->post('username')); Then, on an admin-page you have to check any of those values... Code: $this->load->library('session'); CodeIgniters session library - how to? - El Forum - 04-13-2008 [eluser]v33s[/eluser] Hello! Thanks a lot Seppo. That`s I need! Code: if (!$this->session->userdata('is_admin')) Code: array( So I understand it now! ![]() Code: if(!isset($this->session->userdata('is_admin')) CodeIgniters session library - how to? - El Forum - 04-13-2008 [eluser]Seppo[/eluser] No... Isset only works with variables (empty is the same). Also the userdata method returns FALSE when it doesn't exists, not NULL. |