Welcome Guest, Not a member yet? Register   Sign In
Codeigniter session sometimes kicking me out after completing call to a third party API
#4

[eluser]Amitabh Roy[/eluser]
@tomcode
- session library is auto loaded
- Data is validated before posting sending it to the API
- Sometimes they are logged off, and sometimes the browser itself times out.

@InsiteFX
Nope, I am not using ajax for the call.

So it seems there are actually two problem, the browser timing out means the curl is timing out waiting for response from the API. It something I need to get in touch with the API guys.

The other is the session is timing out. I discovered a couple of problems in the session usage. Here are few things I discovered and the fall back strategy I am using.

1. the user_agent was set to a holy 50 characters in the user_sessions table! I have updated it to text. If you peoples recommend to use Varchar(255), it would be awesome if you let me know why its preferable.

2. As @tomcode suggested, sess_match_ip may give different results, I looked around a bit more and came across this excellent post. So now I have updated the $config['sess_match_ip'] to false FALSE;

3. To remove any IE related session issues, I additionally set the $config['sess_match_useragent'] to FALSE; as I came across this post, which seems to suggest that IE juggles the user agent.

4. Another variable that may be affecting the session logouts be sess_time_to_update. I have updated it to 900 from 300. I need to investigate what happens when session refreshes based on sess_time_to_update and if setting a larger value for sess_time_to_update can solve the problem. I need to understand the mechanism how the session refresh works. Right now I am looking at the session class. Any help or pointers is definitely appreciated. What I am worried about is even after these changes if I get logged out when the session refreshes after sess_time_to_update



I cant fully go for a cookie based session, as I have quite some data in the session and of course storing the session data in db is more secure. So my latest session variables are
Code:
$config['sess_cookie_name']  = 'cisessionPLUSSOMEUPPERCASELETTERS';
$config['sess_expiration']  = 7200;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name']  = 'user_sessions';
$config['sess_match_ip']  = FALSE;//updated from true
$config['sess_match_useragent'] = FALSE;//updated from true
$config['sess_time_to_update']  = 900;//updated from 300

I want to get this right, so any comment or pointers are definitely welcome!:-)


Messages In This Thread
Codeigniter session sometimes kicking me out after completing call to a third party API - by El Forum - 07-06-2012, 01:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB