Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeigniter session expires frequently

I'm using codeigniter for my app

what my problem is session is expiring even though user is active on the site.

These are the session settings.. i'm using DB session

$config['sess_cookie_name']     = 'ci_session';
$config['sess_expiration']      = 7200;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']      = 'edu_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;

any solution for this.

help me i have to fix it

here is the codeigniter forum link

like image 485
nani1216 Avatar asked Jul 28 '11 09:07

nani1216


1 Answers

I've had issues with CI sessions expiring randomly. Do you have AJAX or dynamic resources loading the session library? If so, imagine this scenario:

I submit an ajax request (which passes in my CI session id with the cookie), and it returns the results, BUT I'm also submitting some other request (loading a dynamic image, another AJAX request, etc.) that immediately follows the first request. The first request might trigger the 300 second "it's time to update" event, and pass back a new cookie, but the additional request is sending the old session id, right?

So, CodeIgniter says "hey you, you can't do that" and creates a new session, invalidating both cookies my browser now doesn't know what to do with.

Here's a forum link I posted a while back that goes into more detail: http://codeigniter.com/forums/viewthread/172415/

like image 200
landons Avatar answered Oct 05 '22 02:10

landons