Really Simple User Authentication

Posted on 17 September, 2008
Find out how to create a simple, easy to use user authentication system in CodeIgniter.

Watch Now!



Show Notes

Auth.php Library: <?php class Auth { function Auth() { $this->ci =& get_instance(); $this->ci->load->database(); $this->ci->load->library("session"); } function login($username, $password) { $this->ci->db->where("username", $username); $this->ci->db->where("password", $password); if (!$this->ci->db->get("users")) { return FALSE; } else { $this->ci->session->set_userdata("login", 1); return TRUE; } } function logged_in() { if (!$this->ci->session->userdata("login")==1) { return FALSE; } else { return TRUE; } } function logout() { $this->ci->session->sess_destroy(); return TRUE; } }
Download in: .avi format