Simple example
Before trying the example make sure you have follow installation instruction first.
Using DX Auth library it's pretty straight forward and simple, for example let's create a class named Auth in Auth controller.
class Auth extends Controller
{
function Auth()
{
parent::Controller();
// Load library
$this->load->library('DX_Auth');
}
function login()
{
// Login using username 'test' and password 'helloworld'
$this->dx_auth->login('test', 'helloworld');
}
function logout()
{
// Logout user
$this->dx_auth->logout();
}
function register()
{
// Register a user with username 'john', password 'johnpassword', and email 'john@yourmail.com'
if ($user = $this->dx_auth->register('john', 'johnpassword', 'john@yourmail.com'))
{
echo 'Welcome '.$user->username;
}
else
{
echo 'Failed to register';
}
}
function hello()
{
// Check if user is logged in or not
if ($this->dx_auth->is_logged_in())
{
echo 'Hello world';
}
else
{
echo 'Not logged in';
}
}
}
By just looking these example, i think you already get a grip how easy and simple to use DX Auth library.
If you are interested, here is the more advanced example.