Good day
I use authorization with Ion Auth. Registraition work and all good, but my code is so bad. I use it each controller in order to understand whether the user is registered.
PHP Code:
private $logged_in;
private $login;
public function __construct()
{
parent::__construct();
$this->load->helper('cookie');
$this->load->model('login_model');
if($this->session->userdata('logged_in')){
$this->logged_in = true;
$this->login = $this->session->userdata('login');
}
else{
if(get_cookie('identity') && get_cookie('remember_code')){
if($this->login_model->autorize_cookie(get_cookie('identity'),get_cookie('remember_code'))){
$this->logged_in = true;
$this->login = get_cookie('identity');
}
else{
$this->logged_in = false;
$this->login = '';
}
}
else{
$this->logged_in = false;
$this->login = '';
}
}
}
public function show() //for example
{
$CI = & get_instance ();
$CI->load->view('includes/head');
if($this->logged_in){
$CI->load->view('reg',array('login'=>$this->login,'head_name'=>'Проекты'));
$CI->load->view('project',array('login'=>$this->login));
}
else{
$CI->load->view('login');
}
}
Please, help me, how i can to improve this. Thanks)