lithium\storage\Session::check()

public static method

Checks if a session key is set in any adapter, or if a particular adapter configuration is specified (via 'name' in $options), only that configuration is checked.

Parameters

  • string $key

    The session key to check.

  • array $options

    Optional parameters that this method accepts.

Returns

boolean

Filter

This method can be filtered.

Source

	public static function check($key, array $options = array()) {
		$defaults = array('name' => null, 'strategies' => true);
		$options += $defaults;
		$methods = array();

		if ($name = $options['name']) {
			$methods = array($name => static::adapter($name)->check($key, $options));
		} else {
			foreach (static::$_configurations as $name => $config) {
				if ($method = static::adapter($name)->check($key, $options)) {
					$methods[$name] = $method;
				}
			}
		}
		$params = compact('key', 'options');
		$result = false;

		foreach ($methods as $name => $method) {
			$settings = static::_config($name);
			$filters = $settings['filters'];
			$result = static::_filter(__FUNCTION__, $params, $method, $filters) || $result;
		}
		if ($options['strategies']) {
			$options += array('key' => $key, 'mode' => 'LIFO', 'class' => __CLASS__);
			return static::applyStrategies(__FUNCTION__, $name, $result, $options);
		}
		return $result;
	}