CodeIgniter session class not working in Chrome CodeIgniter session class not working in Chrome google-chrome google-chrome

CodeIgniter session class not working in Chrome


I have also faced this situation and fixed it by increasing session expiry to one day.

UPDATE

Why it works by extending session expiry?


This problem occurs due to difference between timezones of user and webserver location e.g. I live in Pakistan which is 10 hours ahead of US timezone and my server is in US. I request the page at 17/10/2012 14:00 at Pakistan time. The time in US is 17/10/2012 4:00 since webserver is in US and session expiry is set to 2 hours the cookie sent by server is set to expire at 17/10/2012 6:00. Now browser interacts with your local pc time and it gets time 17/10/2012 14:00 therefore it deletes the cookie or your cookie always refreshed on your request. Therefore its best to set session expiry to 1 day because the largest timezone difference is 17 hours between new zealand and US (i am not sure about difference may be i am wrong). So your cookie will at least keep alive for 7 hours


just to add my experience, I'm using Codeigniter 2.1.4,

Issue: sessions on Chrome didn't last more than a couple minutes, or get logged out while doing ajax requests. I tried several approachs: (changed sess_cookie_name, longer sess_expiration time).

I just found that setting sess_encrypt_cookie to FALSE fixed the chrome logout issue.

$config['sess_encrypt_cookie'] = FALSE;

Not sure why, maybe cookie length issue on chrome (as far as I know encryption increases a lot a string length).

I know encrypting adds an extra level of security, but as far as I've read, the data stored in the cookie is not sensitive.

Hope it helps!


I changed the sess_match_useragent param to false in the config.php

$config['sess_match_useragent'] = FALSE;

And the problem with google chrome was resolved.