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

[eluser]waspfactoryuk[/eluser]
[quote author="drewbee" date="1233279357"]I will probably have to come up with a way to notify ajax calls to force the session to not regenerate the id, and leave it strictly for main browser calls unfortunately.[/quote]

I'm quickly coming to that conclusion too...

Having worked through Sessions.php and how it works in relation to AJAX, I think I now fully appreciate the problem. The CodeIgniter documentation says:

Quote:When a page is loaded, the session class will check to see if valid session data exists in the user's session cookie. If sessions data does not exist (or if it has expired) a new session will be created and saved in the cookie. If a session does exist, its information will be updated and the cookie will be updated. With each update, the session_id will be regenerated.

So, if the sess_time_to_update time has passed, or if session data is changed, the session_id will automatically be changed. CodeIgniter relies on sess_update() to update the client's cookie expiry so if sess_update is not called then the session cookie will eventually expire and the session will die.

AJAX requires that the session_id remains constant and does not change. This is not achievable using the CodeIgniter sessions implementation as there is currently no way to turn off the changing of the session ID.

So, the bad news is that our workarounds here don't work as they don't prevent the change of session ID in all circumstances and still allow the cookie expiry to be reset Sad

What I think anyone using AJAX in an environment using sessions for logon security needs is a modification that allows us to switch off the changing of the session ID so it remains constant as per native sessions - or at least allows us to trigger it manually from within a non-AJAX controller. An extra config parameter would be nice to turn it on and off.

Time to start hacking it about Smile


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