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 = []) {
		$defaults = ['name' => null, 'strategies' => true];
		$options += $defaults;
		$methods = [];

		if ($name = $options['name']) {
			$methods = [$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) {
			$result = Filters::run(get_called_class(), __FUNCTION__, $params, $method) || $result;
		}
		if ($options['strategies']) {
			return static::applyStrategies(__FUNCTION__, $name, $result, $options + [
				'mode' => 'LIFO',
				'key' => $key,
				'class' => __CLASS__
			]);
		}
		return $result;
	}