Welcome Guest, Not a member yet? Register   Sign In
Is this a bug in CI or am I doing something wrong (Session related)

(This post was last modified: 12-23-2015, 09:33 PM by behnampmdg3.)


I am using CI 2.1.4.

Sometimes randomly users get logged out.

I see the cookie exists in the cookie tab and the expiry is in a month. But it keeps redirecting me to the login page and print_r($_SESSION) prints: Undefined variable: _SESSION

This is how I log them in:

PHP Code:
$newdata = array('username'  => $data['member_details'][0]->first_name,'email'  => $data['member_details'][0]->email'member_id'  => $data['member_details'][0]->id'logged_in' => TRUE);
This is how I check if the user is logged in or not:

PHP Code:
public function logged()
           $CI =& get_instance();
->logged $CI->session->userdata['logged_data']['logged_in'];
                   return true;
                   if($CI->uri->segment(1)!='scan' && $CI->uri->segment(1)!='login' && $CI->uri->segment(1)!='forgot_password' && $CI->uri->segment(1)!='auth' && $CI->uri->segment(1)!='new_password' && $CI->uri->segment(1)!='signup' && $CI->uri->segment(1)!='forgot-password')
                           $newdata = array('back_url'  => current_url());
(base_url('login'), 'location'301);
                   return FALSE;

PHP Code:
$config['sess_cookie_name'       'ci_session_web';
$config['sess_expiration'       2678400;
$config['sess_expire_on_close'   FALSE;
$config['sess_encrypt_cookie'   FALSE;
$config['sess_use_database'   TRUE;
$config['sess_table_name'       'ci_sessions';
$config['sess_match_ip'       FALSE;
$config['sess_match_useragent'   TRUE;
$config['sess_time_to_update'   300

Cookie tab shows this:


a:4:{s:10:"session_id";s:32:"862a8cabffc1f3974f6e5ca4b5b29fe4";s:10:"ip_address";s:13:" "
;s:10:"user_agent";s:82:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:43.0) Gecko/20100101 Firefox

Thank you

I am pretty sure it was a bug. Because I started using this library and it seems to be fixed:


Theme © iAndrew 2016 - Forum software by © MyBB