public function get(string $key = null)
	{
		if (! empty($key) && $value = dot_array_search($key, $_SESSION))
		{
			return $value;
		}
		elseif (empty($_SESSION))
		{
			return [];
		}

		if (! empty($key))
		{
			return null;
		}

		$userdata = [];
		$_exclude = array_merge(
			['__ci_vars'], $this->getFlashKeys(), $this->getTempKeys()
		);

		$keys = array_keys($_SESSION);
		foreach ($keys as $key)
		{
			if (! in_array($key, $_exclude, true))
			{
				$userdata[$key] = $_SESSION[$key];
			}
		}

		return $userdata;
	}
public function get(string $key = null)
	{
		if (! empty($key) && $value = dot_array_search($key, $_SESSION))
		{
			return $value;
		}
		elseif (empty($_SESSION))
		{
			return [];
		}

		if (! empty($key))
		{
			return null;
		}

		$userdata = [];
		$_exclude = array_merge(
			['__ci_vars'], $this->getFlashKeys(), $this->getTempKeys()
		);

		$keys = array_keys($_SESSION);
		foreach ($keys as $key)
		{
			if (! in_array($key, $_exclude, true))
			{
				$userdata[$key] = $_SESSION[$key];
			}
		}

		return $userdata;
	}
public function get ( string $ key = null ) { if ( ! empty ( $ key ) && $ value = dot_array_search ( $ key , $ _SESSION ) ) { return $ value ; } elseif ( empty ( $ _SESSION ) ) { return [ ] ; } if ( ! empty ( $ key ) ) { return null ; } $ userdata = [ ] ; $ _exclude = array_merge ( [ '__ci_vars' ] , $ this -> getFlashKeys ( ) , $ this -> getTempKeys ( ) ) ; $ keys = array_keys ( $ _SESSION ) ; foreach ( $ keys as $ key ) { if ( ! in_array ( $ key , $ _exclude , true ) ) { $ userdata [ $ key ] = $ _SESSION [ $ key ] ; } } return $ userdata ; }
Get user data that has been set in the session.

If the property exists as "normal", returns it.
Otherwise, returns an array of any temp or flash data values with the
property key.

Replaces the legacy method $session->userdata();

@param  string $key Identifier of the session property to retrieve
@return array|null	The property value(s)
Get user data that has been set in the session .