From cc594f8a420498c2ad37f5ac5e981c895fa02a14 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Mon, 19 Sep 2011 22:05:54 +0200 Subject: [PATCH] Fix bug with session library generating multiple sessions on ajax requests --- application/libraries/MY_Session.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/application/libraries/MY_Session.php b/application/libraries/MY_Session.php index 0f83965..497bffe 100644 --- a/application/libraries/MY_Session.php +++ b/application/libraries/MY_Session.php @@ -118,7 +118,13 @@ class MY_Session extends CI_Session { } $oldSessionId = $this->userdata['session_id']; - $newSessionId = $this->generateHash(); + + // don't change the session ID on ajax requests + if ($this->CI->input->is_ajax_request()) { + $newSessionId = $oldSessionId; + } else { + $newSessionId = $this->generateHash(); + } // update the session data in the session data array $this->userdata['session_id'] = $newSessionId;