![]() |
Losing sessions - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Losing sessions (/showthread.php?tid=32263) |
Losing sessions - El Forum - 07-18-2010 [eluser]stef25[/eluser] I have an app that I'm developing on localhost with a staging environment on a remote server. On my localhost I seem to always lose my sessions, after a matter of minutes. I get redirected back to my login page, which is the normal action for when I'm logged out. So far I have not found a particular action that seems to trigger it. For some reason, with the same codebase, this does not happen on the remote environment. I just noticed that once the bug has "occurred" (ie I'm logged out), a new row is added in the sessions table. So it seems to be losing the connection between my computer and the session (?) How can I start debugging this? My session config for both environments is below Code: $config['sess_cookie_name'] = 'ci_session'; Losing sessions - El Forum - 07-18-2010 [eluser]WanWizard[/eluser] Make sure the cookie domain and path are correct. Domain should be equal to the hostname in the base_url. Are you using ajax calls? If so, they can cause the session_id to rotate (in your setup every 300 seconds), while the cookie hasn't been updated. You have to disable calls to sess_update() when processing an ajax request. Search the forum, solutions have been posted for this problem. Losing sessions - El Forum - 07-18-2010 [eluser]stef25[/eluser] Thanks for that, cookie domain was def wrong. What should the path be? User guide doesn't mention anything about this. Losing sessions - El Forum - 07-18-2010 [eluser]WanWizard[/eluser] Normally, it's equal to the path in your base_url. If your application is installed in the docroot '/' is ok. |