I'm working on user login system in codeigniter. When user clicks on login button the username and password are verified and the data is store in $this->session->set_userdata($arr);
session library and the page redirects to home.php
. Till here works fine but when is try to access the session in home.php
as print_r($this->session->userdata);
. it give me this errors
Here is the Controller code : Login.php
function login_user(){
$login_btn = $this->input->post('login_btn');
if($login_btn == TRUE){
$arr['login'] = array(
'username'=>$this->input->post('username'),
'password'=>$this->input->post('password')
);
$query = $this->Login_model->users_login($arr);
if($query->num_rows() > 0 && $query->num_rows() == 1){
$this->load->library('session');
$this->session->set_userdata($arr);
redirect('Login/redirec_To_home','refresh');
}
else
{
$this->index();
}
}
else
{
$this->index();
}
}
function redirec_To_home(){
$this->load->view('login/home');
}
Here is the view html file name : path views/login/home.php
<?php
print_r($this->session->userdata); //ERRORS SHOWN IN THIS LINE NUMBER : 13
?>