I'm trying to send the session
variable to another controller
but when i use r_print()
it shows nothing and there is condition applied which returns null
.
<?php
// library/login_lib.php
class Login_lib
{
public function logged_in()
{
$CI = & get_instance();
return ($CI->session->userdata('userdata')['is_logged_in'])
? $CI->session->userdata('userdata')['is_logged_in'] : Null;
}
}
?>
<?php
// another file common_helper.php
if( !function_exists('authentication_user') )
{
function authentication_user()
{
$CI = & get_instance();
if( !$CI->login_lib->logged_in() )
{
$CI->session->set_flashdata('error', 'Please login with username and password');
if( $CI->input->is_ajax_request() )
{
echo 'session_expire';
die();
}
else
{
redirect();
}
}
}
}
There is another controller called Dashboard
where i calling the above function authentication_user()
. What i want now i want to call true from the login_lib which i am not actually. I don't know why its blocking to view the Login session.
Thanks in advance
return $CI->session->userdata('is_logged_in') ? $CI->session->userdata('is_logged_in') : Null;
syntax for getting session data in codeigniter is
$this->session->userdata('session_key');