Welcome Guest, Not a member yet? Register   Sign In
Solution to session data loss when using AJAX
#22

[eluser]Chillahan[/eluser]
Guys, I too am confused by this. Some questions:

a) The initial fix here would fix the race condition, right, because as long as they're all AJAX requests that are racing one another, then the session will never update the id, and all will be good. So I am confused why this does not work for slowgary (unless his issue is with regular requests racing, not just AJAX).

b) I experimented with CSRF library (see post URL below). There, it implicitly trusts cookie if set, and does not regenerate key. But once the cookie expires, there is still a problem.

http://ellislab.com/forums/viewthread/189915/

c) To expand on above, I don't get WHY there is a problem (with CSRF or with Session), because when I set my own cookie, I can see it being created in the browser's cookie list in real-time! I.e., I fire an AJAX request, the controller sets a cookie using the cookie helper (which is same as input setter), and I see the cookie appear, and all this is while the JavaScript is timing out for 10 seconds so that I can be sure nothing else happens before cookie appears.

To me it seems there must be some underlying way the cookie is being set by CI in the Session and CSRF that is somehow different, or something in the order of preparation of the return, but I haven't looked into it and cannot imagine what would differ. But doesn't it seem that both the Session and CSRF issues could be fixed with AJAX if the underlying code in each simply set the cookie in a way that works like the way it works when I set it manually during an AJAX request?

Or are there differences in cookie availability during AJAX requests among browsers/platforms that make the setting of a cookie during such request unreliable as a whole, and thus a nonstarter?


Messages In This Thread
Solution to session data loss when using AJAX - by El Forum - 12-17-2009, 06:15 AM
Solution to session data loss when using AJAX - by El Forum - 12-17-2009, 06:48 AM
Solution to session data loss when using AJAX - by El Forum - 12-17-2009, 07:12 AM
Solution to session data loss when using AJAX - by El Forum - 03-13-2010, 04:17 PM
Solution to session data loss when using AJAX - by El Forum - 05-10-2010, 06:33 AM
Solution to session data loss when using AJAX - by El Forum - 07-27-2010, 12:49 AM
Solution to session data loss when using AJAX - by El Forum - 10-11-2010, 03:31 PM
Solution to session data loss when using AJAX - by El Forum - 10-11-2010, 04:49 PM
Solution to session data loss when using AJAX - by El Forum - 10-11-2010, 05:29 PM
Solution to session data loss when using AJAX - by El Forum - 10-11-2010, 06:47 PM
Solution to session data loss when using AJAX - by El Forum - 10-12-2010, 12:33 AM
Solution to session data loss when using AJAX - by El Forum - 10-12-2010, 06:29 AM
Solution to session data loss when using AJAX - by El Forum - 10-12-2010, 07:52 AM
Solution to session data loss when using AJAX - by El Forum - 10-12-2010, 08:06 AM
Solution to session data loss when using AJAX - by El Forum - 10-12-2010, 08:13 AM
Solution to session data loss when using AJAX - by El Forum - 10-12-2010, 09:03 AM
Solution to session data loss when using AJAX - by El Forum - 10-12-2010, 10:01 AM
Solution to session data loss when using AJAX - by El Forum - 10-13-2010, 03:01 AM
Solution to session data loss when using AJAX - by El Forum - 10-13-2010, 03:18 AM
Solution to session data loss when using AJAX - by El Forum - 01-20-2011, 06:58 AM
Solution to session data loss when using AJAX - by El Forum - 05-18-2011, 05:00 PM
Solution to session data loss when using AJAX - by El Forum - 05-25-2011, 12:21 PM
Solution to session data loss when using AJAX - by El Forum - 05-25-2011, 03:33 PM
Solution to session data loss when using AJAX - by El Forum - 05-25-2011, 03:54 PM
Solution to session data loss when using AJAX - by El Forum - 05-25-2011, 07:33 PM
Solution to session data loss when using AJAX - by El Forum - 05-26-2011, 08:43 AM
Solution to session data loss when using AJAX - by El Forum - 07-11-2011, 06:10 AM
Solution to session data loss when using AJAX - by El Forum - 07-11-2011, 07:43 AM
Solution to session data loss when using AJAX - by El Forum - 07-11-2011, 08:56 AM
Solution to session data loss when using AJAX - by El Forum - 07-11-2011, 01:21 PM
Solution to session data loss when using AJAX - by El Forum - 08-20-2012, 12:05 PM
Solution to session data loss when using AJAX - by El Forum - 08-23-2012, 08:50 AM
Solution to session data loss when using AJAX - by El Forum - 08-23-2012, 10:20 AM
Solution to session data loss when using AJAX - by El Forum - 08-23-2012, 01:00 PM
Solution to session data loss when using AJAX - by El Forum - 08-23-2012, 01:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB