[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/Session_driver.php b/system/libraries/Session/Session_driver.php
index 47376da..64b4bb5 100644
--- a/system/libraries/Session/Session_driver.php
+++ b/system/libraries/Session/Session_driver.php
@@ -74,6 +74,18 @@
 	 */
 	protected $_session_id;
 
+	/**
+	 * Success and failure return values
+	 *
+	 * Necessary due to a bug in all PHP 5 versions where return values
+	 * from userspace handlers are not handled properly. PHP 7 fixes the
+	 * bug, so we need to return different values depending on the version.
+	 *
+	 * @see	https://wiki.php.net/rfc/session.user.return-value
+	 * @var	mixed
+	 */
+	protected $_success, $_failure;
+
 	// ------------------------------------------------------------------------
 
 	/**
@@ -85,6 +97,17 @@
 	public function __construct(&$params)
 	{
 		$this->_config =& $params;
+
+		if (is_php('7'))
+		{
+			$this->_success = TRUE;
+			$this->_failure = FALSE;
+		}
+		else
+		{
+			$this->_success = 0;
+			$this->_failure = -1;
+		}
 	}
 
 	// ------------------------------------------------------------------------