07-02-2016, 05:35 AM
Good day.
I broke my brain with this problem.
This is code in controller Login
After autorization if i put login button, i see that $this->logged_in is TRUE. ANd redirect to main page.
But this code main controller
And in function index() $this->logged_in is FALSE
Why? Thanks for help
I broke my brain with this problem.
This is code in controller Login
PHP Code:
private $logged_in;
private $login;
public function __construct()
{
parent::__construct();
$this->load->model('login_model');
if($this->session->userdata('logged_in')){
$this->logged_in = true;
$this->login = $this->session->userdata('login');
}
else{
$this->logged_in = false;
$this->login = '';
}
}
public function index()
{
$data_r=array();
$CI = & get_instance ();
$CI->load->view('site_head',$data_r);
$CI->load->view('site_reg',array('logged_in'=>$this->logged_in,'login'=>$this->login));
$CI->load->view('site_header');
if($this->logged_in){
redirect('/', 'location');
}
else{
$CI->load->view('login_site',array('logged_in'=>$this->logged_in));
}
$CI->load->view('site_footer');
}
But this code main controller
PHP Code:
private $logged_in;
private $login;
public function __construct()
{
parent::__construct();
//$this->load->library('session');
if($this->session->userdata('logged_in')){
$this->logged_in = true;
}
else{
$this->logged_in = false;
}
}
And in function index() $this->logged_in is FALSE
Why? Thanks for help