From 68f098142cb71f6a57f74ce34b5f58616cc1ed2f Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 27 Apr 2012 10:38:32 -0400 Subject: Fix calendar and session libraries --- system/libraries/Session.php | 129 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) (limited to 'system/libraries/Session.php') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 3515764ce..3fa446d84 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -36,26 +36,151 @@ */ class CI_Session { + /** + * Whether to encrypt the session cookie + * + * @var bool + */ public $sess_encrypt_cookie = FALSE; + + /** + * Whether to use to the database for session storage + * + * @var bool + */ public $sess_use_database = FALSE; + + /** + * Name of the database table in which to store sessions + * + * @var string + */ public $sess_table_name = ''; + + /** + * Length of time (in seconds) for sessions to expire + * + * @var int + */ public $sess_expiration = 7200; + + /** + * Whether to kill session on close of browser window + * + * @var bool + */ public $sess_expire_on_close = FALSE; + + /** + * Whether to match session on ip address + * + * @var bool + */ public $sess_match_ip = FALSE; + + /** + * Whether to match session on user-agent + * + * @var bool + */ public $sess_match_useragent = TRUE; + + /** + * Name of session cookie + * + * @var string + */ public $sess_cookie_name = 'ci_session'; + + /** + * Session cookie prefix + * + * @var string + */ public $cookie_prefix = ''; + + /** + * Session cookie path + * + * @var string + */ public $cookie_path = ''; + + /** + * Session cookie domain + * + * @var string + */ public $cookie_domain = ''; + + /** + * Whether to set the cookie only on HTTPS connections + * + * @var bool + */ public $cookie_secure = FALSE; + + /** + * Whether cookie should be allowed only to be sent by the server + * + * @var bool + */ public $cookie_httponly = FALSE; + + /** + * Interval at which to update session + * + * @var int + */ public $sess_time_to_update = 300; + + /** + * Key with which to encrypt the session cookie + * + * @var string + */ public $encryption_key = ''; + + /** + * String to indicate flash data cookies + * + * @var string + */ public $flashdata_key = 'flash'; + + /** + * Function to use to get the current time + * + * @var string + */ public $time_reference = 'time'; + + /** + * Probablity level of garbage collection of old sessions + * + * @var int + */ public $gc_probability = 5; + + /** + * Session data + * + * @var array + */ public $userdata = array(); + + /** + * Reference to CodeIgniter instance + * + * @var object + */ public $CI; + + /** + * Current time + * + * @var int + */ public $now; /** @@ -63,6 +188,8 @@ class CI_Session { * * The constructor runs the session routines automatically * whenever the class is instantiated. + * + * @param array */ public function __construct($params = array()) { @@ -525,6 +652,7 @@ class CI_Session { /** * Delete a session variable from the "userdata" array * + * @param array * @return void */ public function unset_userdata($newdata = array()) @@ -664,6 +792,7 @@ class CI_Session { /** * Write the session cookie * + * @param mixed * @return void */ protected function _set_cookie($cookie_data = NULL) -- cgit v1.2.3-24-g4f1b From 4c316b6bdfa970e98127ea280fcc77ff1288190f Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Fri, 4 May 2012 11:32:48 +0200 Subject: unset userdata --- system/libraries/Session.php | 45 +++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'system/libraries/Session.php') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 3fa446d84..3195f0a91 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -36,146 +36,146 @@ */ class CI_Session { - /** + /** * Whether to encrypt the session cookie * * @var bool */ public $sess_encrypt_cookie = FALSE; - + /** * Whether to use to the database for session storage * * @var bool */ public $sess_use_database = FALSE; - + /** * Name of the database table in which to store sessions * * @var string */ public $sess_table_name = ''; - + /** * Length of time (in seconds) for sessions to expire * * @var int */ public $sess_expiration = 7200; - + /** * Whether to kill session on close of browser window * * @var bool */ public $sess_expire_on_close = FALSE; - + /** * Whether to match session on ip address * * @var bool */ public $sess_match_ip = FALSE; - + /** * Whether to match session on user-agent * * @var bool */ public $sess_match_useragent = TRUE; - + /** * Name of session cookie * * @var string */ public $sess_cookie_name = 'ci_session'; - + /** * Session cookie prefix * * @var string */ public $cookie_prefix = ''; - + /** * Session cookie path * * @var string */ public $cookie_path = ''; - + /** * Session cookie domain * * @var string */ public $cookie_domain = ''; - + /** * Whether to set the cookie only on HTTPS connections * * @var bool */ public $cookie_secure = FALSE; - + /** * Whether cookie should be allowed only to be sent by the server * * @var bool */ public $cookie_httponly = FALSE; - + /** * Interval at which to update session * * @var int */ public $sess_time_to_update = 300; - + /** * Key with which to encrypt the session cookie * * @var string */ public $encryption_key = ''; - + /** * String to indicate flash data cookies * * @var string */ public $flashdata_key = 'flash'; - + /** * Function to use to get the current time * * @var string */ public $time_reference = 'time'; - + /** * Probablity level of garbage collection of old sessions * * @var int */ public $gc_probability = 5; - + /** * Session data * * @var array */ public $userdata = array(); - + /** * Reference to CodeIgniter instance * * @var object */ public $CI; - + /** * Current time * @@ -570,6 +570,9 @@ class CI_Session { $this->cookie_domain, 0 ); + + // Kill session data + $this->userdata = array(); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 5645479c622eb36cf9869797896dc0921568c4a9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 17 May 2012 14:32:19 +0300 Subject: Clean up the libraries --- system/libraries/Session.php | 1 + 1 file changed, 1 insertion(+) (limited to 'system/libraries/Session.php') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 3195f0a91..783109a60 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -190,6 +190,7 @@ class CI_Session { * whenever the class is instantiated. * * @param array + * @return void */ public function __construct($params = array()) { -- cgit v1.2.3-24-g4f1b From 55a6ddb0c7bab1149bb1ddfa3a1aff46612c91d4 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 23 May 2012 18:37:24 +0100 Subject: Input, Session and Cookie get's will return NULL. Read more about this change here: http://codeigniter.com/forums/viewthread/215833 --- system/libraries/Session.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/libraries/Session.php') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 783109a60..4d6aa0ce8 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -276,7 +276,7 @@ class CI_Session { $session = $this->CI->input->cookie($this->sess_cookie_name); // No cookie? Goodbye cruel world!... - if ($session === FALSE) + if ($session === NULL) { log_message('debug', 'A session cookie was not found.'); return FALSE; @@ -586,7 +586,7 @@ class CI_Session { */ public function userdata($item) { - return isset($this->userdata[$item]) ? $this->userdata[$item] : FALSE; + return isset($this->userdata[$item]) ? $this->userdata[$item] : NULL; } // -------------------------------------------------------------------- @@ -715,7 +715,7 @@ class CI_Session { { // 'old' flashdata gets removed. Here we mark all // flashdata as 'new' to preserve it from _flashdata_sweep() - // Note the function will return FALSE if the $key + // Note the function will return NULL if the $key // provided cannot be found $value = $this->userdata($this->flashdata_key.':old:'.$key); -- cgit v1.2.3-24-g4f1b From d261b1e89c3d4d5191036d5a5660ef6764e593a0 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:12:16 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/libraries --- system/libraries/Session.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'system/libraries/Session.php') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 4d6aa0ce8..cc992a5b8 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -206,7 +206,7 @@ class CI_Session { $this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key); } - if ($this->encryption_key == '') + if ($this->encryption_key === '') { show_error('In order to use the Session class you are required to set an encryption key in your config file.'); } @@ -215,13 +215,13 @@ class CI_Session { $this->CI->load->helper('string'); // Do we need encryption? If so, load the encryption class - if ($this->sess_encrypt_cookie == TRUE) + if ($this->sess_encrypt_cookie === TRUE) { $this->CI->load->library('encrypt'); } // Are we using a database? If so, load it - if ($this->sess_use_database === TRUE && $this->sess_table_name != '') + if ($this->sess_use_database === TRUE && $this->sess_table_name !== '') { $this->CI->load->database(); } @@ -232,7 +232,7 @@ class CI_Session { // Set the session length. If the session expiration is // set to zero we'll set the expiration two years from now. - if ($this->sess_expiration == 0) + if ($this->sess_expiration === 0) { $this->sess_expiration = (60*60*24*365*2); } @@ -283,7 +283,7 @@ class CI_Session { } // Decrypt the cookie data - if ($this->sess_encrypt_cookie == TRUE) + if ($this->sess_encrypt_cookie === TRUE) { $session = $this->CI->encrypt->decode($session); } @@ -320,14 +320,14 @@ class CI_Session { } // Does the IP match? - if ($this->sess_match_ip == TRUE && $session['ip_address'] !== $this->CI->input->ip_address()) + if ($this->sess_match_ip === TRUE && $session['ip_address'] !== $this->CI->input->ip_address()) { $this->sess_destroy(); return FALSE; } // Does the User Agent Match? - if ($this->sess_match_useragent == TRUE && trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120))) + if ($this->sess_match_useragent === TRUE && trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120))) { $this->sess_destroy(); return FALSE; @@ -338,12 +338,12 @@ class CI_Session { { $this->CI->db->where('session_id', $session['session_id']); - if ($this->sess_match_ip == TRUE) + if ($this->sess_match_ip === TRUE) { $this->CI->db->where('ip_address', $session['ip_address']); } - if ($this->sess_match_useragent == TRUE) + if ($this->sess_match_useragent === TRUE) { $this->CI->db->where('user_agent', $session['user_agent']); } @@ -359,7 +359,7 @@ class CI_Session { // Is there custom data? If so, add it to the main session array $row = $query->row(); - if (isset($row->user_data) && $row->user_data != '') + if (isset($row->user_data) && $row->user_data !== '') { $custom_data = $this->_unserialize($row->user_data); @@ -809,7 +809,7 @@ class CI_Session { // Serialize the userdata for the cookie $cookie_data = $this->_serialize($cookie_data); - if ($this->sess_encrypt_cookie == TRUE) + if ($this->sess_encrypt_cookie === TRUE) { $cookie_data = $this->CI->encrypt->encode($cookie_data); } @@ -929,7 +929,7 @@ class CI_Session { */ protected function _sess_gc() { - if ($this->sess_use_database != TRUE) + if ($this->sess_use_database !== TRUE) { return; } -- cgit v1.2.3-24-g4f1b From 5036c9caabb12f90b9533d7fb417610e02a652ff Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 4 Jun 2012 15:34:56 +0300 Subject: Revert/optimize some changes from 773ccc318f2769c9b7579630569b5d8ba47b114b and d261b1e89c3d4d5191036d5a5660ef6764e593a0 --- system/libraries/Session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Session.php') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index cc992a5b8..7beedd96b 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -359,7 +359,7 @@ class CI_Session { // Is there custom data? If so, add it to the main session array $row = $query->row(); - if (isset($row->user_data) && $row->user_data !== '') + if ( ! empty($row->user_data)) { $custom_data = $this->_unserialize($row->user_data); -- cgit v1.2.3-24-g4f1b