I am trying to implement a function which logs the oldest session out if the user logs in again or on a different browser.
Currently I have a Problem:
Code:
class MY_Controller extends Controller{
public $data;
public $load_view;
function __construct(){
parent::Controller(); // Always need to call the parent Controller
$this->load->library('ion_auth');
I'm loading the library in my Base_Controller. The auth_ion library has this snipped in its constructor.
Code:
if (!$this->logged_in() && get_cookie('identity') && get_cookie('remember_code'))
{
$this->ci->ion_auth_model->login_remembered_user();
}
My Local Controller has:
Code:
class Welcome extends MY_Controller{
function __construct(){
parent::__construct();
if(!$this->ion_auth->logged_in()) redirect('auth/login');
}
As you can see my local controller checks if the user is logged in, if not redirect him.
With this structure it will run the Logged_in function twice on the same page.
So On my welcome controller it runs the query twice, once from the welcome controller and once from my Base_controller where I have loaded the auth library.
Any ideas how I can just run it once on each of my controller ?