[eluser]veledrom[/eluser]
Hi,
I have a controller which has this validation function in it. Now I have many controllers and have to run this function all. I don't want to replicate same code over and over again all the controllers so please give me a hand to solve this problem. Where should I put this code and how do I call it etc...
Thanks
Code:
class Securedpage extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->site_authentication();
}
public function site_authentication()
{
if($this->session->userdata('login_data'))
{
$login_data_array = $this->session->userdata('login_data');
if(! isset($login_data_array['is_logged_in']) || $login_data_array['is_logged_in'] !== true)
{
redirect('loginout');
}
}
else
{
redirect('loginout');
}
}
}