5

I'm building an application using Codeigniter 3, but users keep getting logged out by random. I thought it might be an issue with using AJAX, as I've read that was a bit buggy, but it happens just randomly while browsing etc, and not any specific time as it can happen repeatedly over a few minutes or not for a while.

I am using ion_auth plugin for authentication etc.

My sessions are stored in the database, Here is the config into from CI:

//$config['sess_driver'] = 'files';
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
//$config['sess_save_path'] = '/home/slight/system/cache/';
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

How can I even debug this? What can be causing it? What can I check for?

Lux
  • 17,835
  • 5
  • 43
  • 73
frobak
  • 557
  • 2
  • 11
  • 30
  • 2
    This will be hard to debug(to say the least). I recommend isolating the build in a virtual machine, get yourself xDebug installed, start logging the session as best as you can and try to reproduce the issue a few times. With xDebug you can step in(and out) of functions, maybe it will give an idea of what goes wrong where. – Andrei Nov 02 '16 at 14:46
  • 4
    You might want to try `$config['sess_match_ip'] = FALSE;` and see if that makes any difference. – DFriend Nov 02 '16 at 15:46
  • 3
    You might also get better results by setting `$config['sess_time_to_update']` to a value that is much closer to `$config['sess_expiration']`. – DFriend Nov 02 '16 at 15:52
  • ok thanks for your comments. I have set the config vars as you suggested above and just testing now! – frobak Nov 02 '16 at 16:07
  • i'm getting this error from past week, couldn't find any solution yet. But it seems like it's problem of plugin authentication, (ion_auth) i'm using the same – Habib Rehman Nov 06 '16 at 10:27
  • @HabibRehman i think for me the sess_match_ip as suggested by DFriend seemed to work. I also switched my sessions to file from database. All seems to be working fine now without ant unexpected logouts! – frobak Nov 08 '16 at 11:40

1 Answers1

1

You might have to try $config['sess_match_ip'] = FALSE;

xlm
  • 6,854
  • 14
  • 53
  • 55