CodeIgniter Forums
AJAX Pagination using session userdata - Not updated fast enough? - 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: AJAX Pagination using session userdata - Not updated fast enough? (/showthread.php?tid=32846)



AJAX Pagination using session userdata - Not updated fast enough? - El Forum - 08-06-2010

[eluser]Unknown[/eluser]
Hi folks,

First of all, hi to everyone, I've been lurking in these forums for a long time, and it's been great help.

I'm building a pagination system to display database results. It's pretty basic stuff : a Previous link, a Next link, and a dropdown menu to choose the amount of results to show (5, 10, 25, 50, 100, 500).

Everything works great. The next, previous and dropdown send an ajax POST request to a controller, which returns the new results. It's very slick and ajaxy.

But I'm having an issue, that I believe might be caused by the session userdata not being saved properly. For example, if the user clicks on NEXT a couple times, once in a while, the results will be the same.

Let me explain again.. Let's say we are seeing results 6 to 10, and the user clicks next to get results 11 to 16, sometimes it will pump back results 6 to 10 again, instead of 11 to 16.

Here's how I programmed it. My controller outputs the results by doing a simple query with START and LIMIT values. The START and LIMIT are determined by user_data session variables. So when a user clicks next or previous, the START variable is increased or decreased by the current LIMIT. And later, the query fetches those variables in the session to do its job.

Could the session variables not be updated fast enough, so that my query is using the old user_data?

Have any of you seen this type of behavior with session variables? I figured I'd ask around before spending two days troubleshooting this.

Thank a lot!


AJAX Pagination using session userdata - Not updated fast enough? - El Forum - 08-06-2010

[eluser]Unknown[/eluser]
Oh, nevermind, I figured it out. (2 minutes after deciding to post here for help of course!)

I had previously set "sess_expiration" to 10 seconds to test something else in my Config, and forgot to put it back to 7200. Therefore, my session was renewed every 10 seconds and it caused some data not to be updated properly.

It works fine now.