Welcome Guest, Not a member yet? Register   Sign In
AJAX and CI Session (v1.7) w/DB
#1

[eluser]Padraig Kennedy[/eluser]
When used together, AJAX requests and the Code Igniter session library (with database storage) do not get along very well.

To frustrate man in the middle attacks, CI regenerates the session every $config["sess_time_to_update"] seconds (default is 5 minutes, I believe). This works by calling the sess_update() method in Session.php every time the session class is initialised.

If it's been more than sess_time_to_update seconds:

1. A new session_id is generated
2. The database is updated with this new session_id
3. The new session_id is sent back to the browser in a cookie.

This is problematic when multiple parallel requests are made. Parallel requests are common when using AJAX. Consider the following scenario: 2 parallel requests are made, just as we exceed the sess_time_to_update threshold. The first one triggers the regeneration of the session_id and returns normally. The second one, however, is still using the old and recently invalidated session_id. A new session is created for this request, which contains none of the userdata and is therefore not marked as logged in. The result is that the user gets logged out sooner than he/she should.

As a temporary work-around, I am planning to simply disable the regeneration of sessions by commenting out the sess_update() at about line 105 of Session.php

I realise that this decreases security somewhat, but our service is provided over SSL, so it is unlikely that a session key could be grabbed mid transmission and since only server generated session ids are accepted, Session Fixation should not be possible.

Any other ideas on how to deal with this? Is there anything else I should worry about after turning off the session update?

Thanks,

Pádraig.


Messages In This Thread
AJAX and CI Session (v1.7) w/DB - by El Forum - 01-15-2009, 09:48 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 01-28-2009, 05:03 PM
AJAX and CI Session (v1.7) w/DB - by El Forum - 01-29-2009, 04:46 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 01-29-2009, 06:20 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 01-29-2009, 07:03 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 01-29-2009, 07:47 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 01-29-2009, 11:41 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 01-29-2009, 01:35 PM
AJAX and CI Session (v1.7) w/DB - by El Forum - 01-29-2009, 01:50 PM
AJAX and CI Session (v1.7) w/DB - by El Forum - 01-29-2009, 03:10 PM
AJAX and CI Session (v1.7) w/DB - by El Forum - 01-29-2009, 05:07 PM
AJAX and CI Session (v1.7) w/DB - by El Forum - 01-29-2009, 05:19 PM
AJAX and CI Session (v1.7) w/DB - by El Forum - 01-29-2009, 05:45 PM
AJAX and CI Session (v1.7) w/DB - by El Forum - 04-08-2009, 04:35 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 04-08-2009, 05:11 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 04-08-2009, 07:23 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 05-13-2009, 03:33 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 05-13-2009, 07:26 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 05-13-2009, 08:38 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 05-14-2009, 03:34 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 05-14-2009, 03:43 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 01-27-2011, 08:11 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 02-07-2012, 03:50 PM
AJAX and CI Session (v1.7) w/DB - by El Forum - 02-07-2012, 05:44 PM
AJAX and CI Session (v1.7) w/DB - by El Forum - 02-18-2014, 02:37 PM
AJAX and CI Session (v1.7) w/DB - by El Forum - 02-18-2014, 04:48 PM
AJAX and CI Session (v1.7) w/DB - by El Forum - 02-19-2014, 03:55 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 02-21-2014, 12:35 PM
AJAX and CI Session (v1.7) w/DB - by El Forum - 02-23-2014, 10:06 AM
AJAX and CI Session (v1.7) w/DB - by El Forum - 02-23-2014, 10:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB