Welcome Guest, Not a member yet? Register   Sign In
Losing sessions
#1

[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';
$config['sess_expiration']        = 7200;
$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']    = FALSE;
$config['sess_time_to_update']     = 300;
$config['cookie_prefix'] = "";
$config['cookie_domain'] = "";
$config['cookie_path'] = "/";
#2

[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.
#3

[eluser]stef25[/eluser]
Thanks for that, cookie domain was def wrong. What should the path be? User guide doesn't mention anything about this.
#4

[eluser]WanWizard[/eluser]
Normally, it's equal to the path in your base_url.
If your application is installed in the docroot '/' is ok.




Theme © iAndrew 2016 - Forum software by © MyBB