Skip to content

Commit 7e087f5

Browse files
committed
Revert if() merge, for readability
1 parent 9c622f3 commit 7e087f5

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

system/libraries/Session.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,28 @@ public function sess_read()
179179
$session = $this->_unserialize($session);
180180

181181
// Is the session data we unserialized an array with the correct format?
182-
if ( ! is_array($session) OR ! isset($session['session_id'], $session['ip_address'], $session['user_agent'], $session['last_activity'])
183-
OR ($session['last_activity'] + $this->sess_expiration) < $this->now // Is the session current?
184-
OR ($this->sess_match_ip == TRUE && $session['ip_address'] !== $this->CI->input->ip_address()) // Does the IP match?
185-
OR ($this->sess_match_useragent == TRUE && trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120))) // Does the User Agent Match?
186-
)
182+
if ( ! is_array($session) OR ! isset($session['session_id'], $session['ip_address'], $session['user_agent'], $session['last_activity']))
183+
{
184+
$this->sess_destroy();
185+
return FALSE;
186+
}
187+
188+
// Is the session current?
189+
if (($session['last_activity'] + $this->sess_expiration) < $this->now)
190+
{
191+
$this->sess_destroy();
192+
return FALSE;
193+
}
194+
195+
// Does the IP match?
196+
if ($this->sess_match_ip == TRUE && $session['ip_address'] !== $this->CI->input->ip_address())
197+
{
198+
$this->sess_destroy();
199+
return FALSE;
200+
}
201+
202+
// Does the User Agent Match?
203+
if ($this->sess_match_useragent == TRUE && trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120)))
187204
{
188205
$this->sess_destroy();
189206
return FALSE;

0 commit comments

Comments
 (0)