Skip to content

Commit 83a793b

Browse files
committed
Improved the session handler so that it does not write unchanged sessions to database.
1 parent efb7dc2 commit 83a793b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

interface/lib/classes/session.inc.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function read ($session_id) {
5656

5757
if (is_array($rec)) {
5858
$this->session_array = $rec;
59-
return $rec['session_data'];
59+
return $this->session_array['session_data'];
6060
} else {
6161
return '';
6262
}
@@ -68,6 +68,11 @@ function write ($session_id, $session_data) {
6868
$this->session_array = array();
6969
}
7070

71+
// Dont write session to DB if session data has not been changed after reading it.
72+
if(isset($this->session_array['session_data']) && $this->session_array['session_data'] != '' && $this->session_array['session_data'] == $session_data) {
73+
return true;
74+
}
75+
7176

7277
if ($this->session_array['session_id'] == '') {
7378
$session_id = $this->db->quote($session_id);

0 commit comments

Comments
 (0)