Fixed _parent references and several minor bugs
diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php
index 9c887d8..7343342 100755
--- a/system/libraries/Session/Session.php
+++ b/system/libraries/Session/Session.php
@@ -64,7 +64,7 @@
 
 		// Get valid drivers list
 		$CI =& get_instance();
-		$this->valid_drivers = array('CI_Session_native', 'CI_Session_cookie');
+		$this->valid_drivers = array('Session_native', 'Session_cookie');
 		$key = 'sess_valid_drivers';
 		$drivers = (isset($params[$key])) ? $params[$key] : $CI->config->item($key);
 		if ($drivers)
@@ -131,7 +131,7 @@
 	public function select_driver($driver)
 	{
 		// Validate driver name
-		$lowername = strtolower($driver);
+		$lowername = strtolower(str_replace('CI_', '', $driver));
 		if (in_array($lowername, array_map('strtolower', $this->valid_drivers)))
 		{
 			// See if regular or lowercase variant is loaded
@@ -177,11 +177,11 @@
 	 * Fetch a specific item from the session array
 	 *
 	 * @param	string	Item key
-	 * @return	string	Item value
+	 * @return	string	Item value or NULL if not found
 	 */
 	public function userdata($item)
 	{
-		// Return value or FALSE if not found
+		// Return value or NULL if not found
 		return ( ! isset($this->userdata[$item])) ? NULL : $this->userdata[$item];
 	}
 
@@ -208,7 +208,7 @@
 		// loop through all userdata
 		foreach ($this->all_userdata() as $key => $val)
 		{
-            // if it contains flashdata, add it
+			// if it contains flashdata, add it
 			if (strpos($key, self::FLASHDATA_KEY.self::FLASHDATA_OLD) !== FALSE)
 			{
 				$out[$key] = $val;
@@ -543,7 +543,7 @@
 		// Call base class decorate first
 		parent::decorate($parent);
 
-		// Call initialize method now that driver has access to $this->parent
+		// Call initialize method now that driver has access to $this->_parent
 		$this->initialize();
 	}
 
@@ -559,7 +559,7 @@
 	public function __call($method, $args = array())
 	{
 		// Make sure the parent library uses this driver
-		$this->parent->select_driver(get_class($this));
+		$this->_parent->select_driver(get_class($this));
 		return parent::__call($method, $args);
 	}
 
diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php
index e39ada0..19ccd41 100755
--- a/system/libraries/Session/drivers/Session_cookie.php
+++ b/system/libraries/Session/drivers/Session_cookie.php
@@ -190,13 +190,13 @@
 		'cookie_domain', 'cookie_secure', 'cookie_httponly', 'sess_time_to_update', 'time_reference', 'cookie_prefix',
 		'encryption_key') as $key)
 		{
-			$this->$key = isset($this->parent->params[$key]) ? $this->parent->params[$key] :
+			$this->$key = isset($this->_parent->params[$key]) ? $this->_parent->params[$key] :
 				$this->CI->config->item($key);
 		}
 
 		if ($this->encryption_key === '')
 		{
-			show_error('In order to use the Session Cookie driver you are required to set an encryption key '.
+			show_error('In order to use the Cookie Session driver you are required to set an encryption key '.
 				'in your config file.');
 		}
 
@@ -309,7 +309,7 @@
 		}
 
 		// Kill the cookie
-		setcookie($this->sess_cookie_name, addslashes(serialize(array())), ($this->now - 31500000),
+		$this->_setcookie($this->sess_cookie_name, addslashes(serialize(array())), ($this->now - 31500000),
 			$this->cookie_path, $this->cookie_domain, 0);
 
 		// Kill session data
@@ -632,11 +632,33 @@
 		$expire = ($this->sess_expire_on_close === TRUE) ? 0 : $this->sess_expiration + time();
 
 		// Set the cookie
-		setcookie($this->sess_cookie_name, $cookie_data, $expire, $this->cookie_path, $this->cookie_domain,
+		$this->_setcookie($this->sess_cookie_name, $cookie_data, $expire, $this->cookie_path, $this->cookie_domain,
 			$this->cookie_secure, $this->cookie_httponly);
 	}
 
 	/**
+	 * Set a cookie with the system
+	 *
+	 * This abstraction of the setcookie call allows overriding for unit testing
+	 *
+	 * @access  protected
+	 * @param   string  Cookie name
+	 * @param   string  Cookie value
+	 * @param   int	 Expiration time
+	 * @param   string  Cookie path
+	 * @param   string  Cookie domain
+	 * @param   bool	Secure connection flag
+	 * @param   bool	HTTP protocol only flag
+	 * @return  void
+	 */
+	protected function _setcookie($name, $value = '', $expire = 0, $path = '', $domain = '', $secure = false,
+	$httponly = false)
+	{
+		// Set the cookie
+		setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);
+	}
+
+	/**
 	 * Serialize an array
 	 *
 	 * This function first converts any slashes found in the array to a temporary
diff --git a/system/libraries/Session/drivers/Session_native.php b/system/libraries/Session/drivers/Session_native.php
index 8388e06..27db942 100755
--- a/system/libraries/Session/drivers/Session_native.php
+++ b/system/libraries/Session/drivers/Session_native.php
@@ -39,7 +39,7 @@
 		foreach (array('sess_cookie_name', 'sess_expire_on_close', 'sess_expiration', 'sess_match_ip',
 		'sess_match_useragent', 'cookie_prefix', 'cookie_path', 'cookie_domain') as $key)
 		{
-			$config[$key] = isset($this->parent->params[$key]) ? $this->parent->params[$key] : $CI->config->item($key);
+			$config[$key] = isset($this->_parent->params[$key]) ? $this->_parent->params[$key] : $CI->config->item($key);
 		}
 
 		// Set session name, if specified