09-14-2010, 07:09 PM
[eluser]kenjis[/eluser]
CI's default 5 min session updating can cause session loss when more than 2 requests come at the same time, most of cases with Ajax calls.
Many people get stuck to this issue.
http://ellislab.com/forums/viewthread/167310/
http://ellislab.com/forums/viewthread/102456/
How about stopping session update in case Ajax call?
Note: You need to send X_REQUESTED_WITH header manually if you use jQuery or so.
CI's default 5 min session updating can cause session loss when more than 2 requests come at the same time, most of cases with Ajax calls.
Many people get stuck to this issue.
http://ellislab.com/forums/viewthread/167310/
http://ellislab.com/forums/viewthread/102456/
How about stopping session update in case Ajax call?
Code:
--- a/system/libraries/Session.php Tue Sep 14 18:45:42 2010 -0500
+++ b/system/libraries/Session.php Wed Sep 15 10:02:06 2010 +0900
@@ -340,6 +340,12 @@
*/
function sess_update()
{
+ // Skip the session update in case Ajax call
+ if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest')
+ {
+ return;
+ }
+
// We only update the session every five minutes by default
if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now)
{
Note: You need to send X_REQUESTED_WITH header manually if you use jQuery or so.