Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Prevent sending multiple Set-Cookie headers. Only runs 'sess_save()' …

…one time right after all other headers are sent before outputting the page contents.

Signed-off-by: Aaron Parecki <aaron@parecki.com>
  • Loading branch information...
commit 7d4aecab0b885eaa62fc1e15864cec09f435cdcc 1 parent f7e23b3
@aaronpk aaronpk authored
View
5 system/core/Output.php
@@ -420,6 +420,11 @@ public function _display($output = '')
}
}
+ if($CI->session) {
+ // Save the session. If using session cookies, this ensures only one "Set-Cookie" header is sent
+ $CI->session->get_driver()->sess_save();
+ }
+
// --------------------------------------------------------------------
// Does the $CI object exist?
View
8 system/libraries/Session/Session.php
@@ -177,6 +177,11 @@ public function select_driver($driver)
}
}
+ public function get_driver()
+ {
+ return $this->current;
+ }
+
// ------------------------------------------------------------------------
/**
@@ -279,9 +284,6 @@ public function set_userdata($newdata = array(), $newval = '')
$this->userdata[$key] = $val;
}
}
-
- // Tell driver data changed
- $this->current->sess_save();
}
// ------------------------------------------------------------------------
View
6 system/libraries/Session/drivers/Session_cookie.php
@@ -512,9 +512,6 @@ protected function _sess_create()
// Add empty user_data field and save the data to the DB
$this->CI->db->set('user_data', '')->insert($this->sess_table_name, $this->userdata);
}
-
- // Write the cookie
- $this->_set_cookie();
}
// ------------------------------------------------------------------------
@@ -555,9 +552,6 @@ protected function _sess_update($force = FALSE)
'session_id' => $this->userdata['session_id']
), array('session_id' => $old_sessid));
}
-
- // Write the cookie
- $this->_set_cookie();
}
// ------------------------------------------------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.