[eluser]InsiteFX[/eluser]
A summing that you have an Auth Library just add this to use database sessions.
Code:
// -----------------------------------------------------------------------
/**
* logged_in()
*
* Check to see if a user is logged in.
*
* Look in the session and return the 'logged_in' field.
*
* @access public
* @return bool
*/
public function logged_in()
{
return ($this->_ci->session->userdata('logged_in') == TRUE) ? TRUE : FALSE;
}
Create an auth_helper in ./application/helpers and autoload it.
Code:
// ------------------------------------------------------------------------
/**
* logged_in()
*
* @access public
* @return bool
*/
if ( ! function_exists('logged_in'))
{
function logged_in()
{
$_ci = get_instance();
return ($_ci->auth->logged_in() == TRUE) ? TRUE : FALSE;
}
}
Then you can check if the user is logged like this.
Code:
if (logged_in())
{
// code for user is logged in.
}
else
{
// code for user is not logged in.
}
You will need to set the logged_in field in the session user_data when they log in.