CodeIgniter Forums
Solution to session data loss when using AJAX - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Solution to session data loss when using AJAX (/showthread.php?tid=25591)

Pages: 1 2 3 4


Solution to session data loss when using AJAX - El Forum - 08-20-2012

[eluser]froozle[/eluser]
There is a race condition with the CI session.
A fix is proposed here:
http://www.hiretheworld.com/blog/tech-blog/codeigniter-session-race-conditions

It's already been submitted to CI on github as a pull request.

https://github.com/EllisLab/CodeIgniter/pull/1713


Solution to session data loss when using AJAX - El Forum - 08-23-2012

[eluser]MissionMan[/eluser]
[quote author="froozle" date="1345489549"]There is a race condition with the CI session.
A fix is proposed here:
http://www.hiretheworld.com/blog/tech-blog/codeigniter-session-race-conditions

It's already been submitted to CI on github as a pull request.

https://github.com/EllisLab/CodeIgniter/pull/1713[/quote]

Forgive my ignorance but I haven't been using CI for long.

I have copied the code from www.hiretheworld.com What file do I put it in and where do I place that file?

Thanks.


Solution to session data loss when using AJAX - El Forum - 08-23-2012

[eluser]froozle[/eluser]
You need to extend the session library.
So Take the content of that file and put it in MY_Session ( if MY_ is the prefix to your extensions - You can find this inside your application/config.php file )

Put the My_Session file inside application/libraries and you should be good to go.

Cheers


Solution to session data loss when using AJAX - El Forum - 08-23-2012

[eluser]WanWizard[/eluser]
[quote author="froozle" date="1345489549"]There is a race condition with the CI session.
A fix is proposed here:
http://www.hiretheworld.com/blog/tech-blog/codeigniter-session-race-conditions

It's already been submitted to CI on github as a pull request.

https://github.com/EllisLab/CodeIgniter/pull/1713[/quote]
Yeah, by a guy that shamelessly takes my old solution (see a few posts back) and puts it forward as his own.

It's not a fix, it's a workaround, and not a very good one, as it will basically only double the session ID rotation timeout. Going for InsiteFX's solution of disabling session ID rotation on ajax calls is a much cleaner workaround, one which works pretty well.


Solution to session data loss when using AJAX - El Forum - 08-23-2012

[eluser]froozle[/eluser]
I'm quite confident he didn't just "take your old solution" and put it forward as his own. That's quite insulting. I didn't read a few posts back. This solution was implemented a while back, and if you have the same one, then that's great. The point of this forum is not to attack anyone, but to provide possible solutions.

If you read the actual post, you'll see that it doesn't just happen on ajax requests. It could happen with normal requests as well. Either way, it works for us Smile