Simple Authentication Library for Code Igniter - EasyAuth

December 1st 2008

Here is a very simple authentication library for the framework Code Igniter. It uses a MySQL database table 'users' to authenticate against. You can find some basic documentation on this library here. 

Enjoy!

1,724 downloads

8 COMMENTS

Erica says...
Perfect, so easy to use and implement, I had it up in running in less than five minutes, thanks!
Wes Edling says...
Sorry about that, I just removed the auth on the documentation. It was meant for something else.
Ernie says...
I am new to codeigniter, could you provide simple example code to login (login.php) and logout (logout.php).
Ernie says...
For my request above, I mean examples using EasyAuth. I don't know how to setup the action for the login form, and I don't see that mentioned anywhere. thx
wes says...
Hey Ernie,

You would want to implement the auth in your controller to limit certain functions. Or you could set it up to auto auth with something like this..


class Blog extends Controller {

function __construct(){

if($this->easyauth->connected == true):

$this->load->view('dashboard');

else:

$this->load->view('login');

endif;

}

}

And be sure to include easy auth in your auto loader configuration.
Ernie says...
So what does the login view look like? I am unclear on how to create the form in the login.php (view) so it uses this library to check and setup the session.
Wes says...
You will want login.php to be your html form that posts the data so EasyAuth can detect the variables. login.php would look something like this.

<html>
<head>
<title>Login Page</title>
</head>
<body>
<form method='post' action='/your-protected-url'>
Username<br />
<input type='text' name='login[username]' value='' /><br /><br />
Password<br />
<input type='password' name='login[password]' value='' /><br /><br />
<input type='submit' value='Login'>
</form>
</body>
</html>
mekong says...
What is your ' action='/your-protected-url'>?

ADD YOUR COMMENT

(optional)
(optional)
Use (Gravatar) for your avatars.