[ci skip] Proper error handling for Sessions on PHP 5

This was actually a PHP bug, see https://wiki.php.net/rfc/session.user.return-value

Also related: #4039
diff --git a/system/libraries/Session/drivers/Session_files_driver.php b/system/libraries/Session/drivers/Session_files_driver.php
index 173b437..f0f055f 100644
--- a/system/libraries/Session/drivers/Session_files_driver.php
+++ b/system/libraries/Session/drivers/Session_files_driver.php
@@ -129,7 +129,7 @@
 			.$name // we'll use the session cookie name as a prefix to avoid collisions
 			.($this->_config['match_ip'] ? md5($_SERVER['REMOTE_ADDR']) : '');
 
-		return TRUE;
+		return $this->_success;
 	}
 
 	// ------------------------------------------------------------------------
@@ -156,13 +156,13 @@
 				if (($this->_file_handle = fopen($this->_file_path.$session_id, 'w+b')) === FALSE)
 				{
 					log_message('error', "Session: File '".$this->_file_path.$session_id."' doesn't exist and cannot be created.");
-					return FALSE;
+					return $this->_failure;
 				}
 			}
 			elseif (($this->_file_handle = fopen($this->_file_path.$session_id, 'r+b')) === FALSE)
 			{
 				log_message('error', "Session: Unable to open file '".$this->_file_path.$session_id."'.");
-				return FALSE;
+				return $this->_failure;
 			}
 
 			if (flock($this->_file_handle, LOCK_EX) === FALSE)
@@ -170,7 +170,7 @@
 				log_message('error', "Session: Unable to obtain lock for file '".$this->_file_path.$session_id."'.");
 				fclose($this->_file_handle);
 				$this->_file_handle = NULL;
-				return FALSE;
+				return $this->_failure;
 			}
 
 			// Needed by write() to detect session_regenerate_id() calls
@@ -187,7 +187,7 @@
 		// See https://github.com/bcit-ci/CodeIgniter/issues/4039
 		elseif ($this->_file_handler === FALSE)
 		{
-			return FALSE;
+			return $this->_failure;
 		}
 		else
 		{
@@ -226,18 +226,18 @@
 		// and we need to close the old handle and open a new one
 		if ($session_id !== $this->_session_id && ( ! $this->close() OR $this->read($session_id) === FALSE))
 		{
-			return FALSE;
+			return $this->_failure;
 		}
 
 		if ( ! is_resource($this->_file_handle))
 		{
-			return FALSE;
+			return $this->_failure;
 		}
 		elseif ($this->_fingerprint === md5($session_data))
 		{
-			return ($this->_file_new)
-				? TRUE
-				: touch($this->_file_path.$session_id);
+			return ( ! $this->_file_new && ! touch($this->_file_path.$session_id))
+				? $this->_failure
+				: $this->_success;
 		}
 
 		if ( ! $this->_file_new)
@@ -260,12 +260,12 @@
 			{
 				$this->_fingerprint = md5(substr($session_data, 0, $written));
 				log_message('error', 'Session: Unable to write data.');
-				return FALSE;
+				return $this->_failure;
 			}
 		}
 
 		$this->_fingerprint = md5($session_data);
-		return TRUE;
+		return $this->_success;
 	}
 
 	// ------------------------------------------------------------------------
@@ -285,10 +285,9 @@
 			fclose($this->_file_handle);
 
 			$this->_file_handle = $this->_file_new = $this->_session_id = NULL;
-			return TRUE;
 		}
 
-		return TRUE;
+		return $this->_success;
 	}
 
 	// ------------------------------------------------------------------------
@@ -305,19 +304,31 @@
 	{
 		if ($this->close())
 		{
-			return file_exists($this->_file_path.$session_id)
-				? (unlink($this->_file_path.$session_id) && $this->_cookie_destroy())
-				: TRUE;
+			if (file_exists($this->_file_path.$session_id))
+			{
+				$this->_cookie_destroy();
+				return unlink($this->_file_path.$session_id)
+					? $this->_success
+					: $this->_failure;
+			}
+
+			return $this->_success;
 		}
 		elseif ($this->_file_path !== NULL)
 		{
 			clearstatcache();
-			return file_exists($this->_file_path.$session_id)
-				? (unlink($this->_file_path.$session_id) && $this->_cookie_destroy())
-				: TRUE;
+			if (file_exists($this->_file_path.$session_id))
+			{
+				$this->_cookie_destroy();
+				return unlink($this->_file_path.$session_id)
+					? $this->_success
+					: $this->_failure;
+			}
+
+			return $this->_success;
 		}
 
-		return FALSE;
+		return $this->_failure;
 	}
 
 	// ------------------------------------------------------------------------
@@ -335,7 +346,7 @@
 		if ( ! is_dir($this->_config['save_path']) OR ($directory = opendir($this->_config['save_path'])) === FALSE)
 		{
 			log_message('debug', "Session: Garbage collector couldn't list files under directory '".$this->_config['save_path']."'.");
-			return FALSE;
+			return $this->_failure;
 		}
 
 		$ts = time() - $maxlifetime;
@@ -362,7 +373,7 @@
 
 		closedir($directory);
 
-		return TRUE;
+		return $this->_success;
 	}
 
-}
+}
\ No newline at end of file