lithium\storage\Session::delete()

public static method

Deletes a named key from a single adapter (if a 'name' option is specified) or all session adapters.

Parameters

  • string $key

    The name of the session key to delete.

  • array $options

    Optional parameters that this method accepts:

    • 'name' string: To force the delete to a specific adapter, specify the name of the configuration (i.e. 'default') here.
    • 'strategies' boolean: Indicates whether or not a configuration's applied strategy classes should be enabled for this operation. Defaults to true.

Returns

boolean

Returns true on successful delete, or false on failure.

Filter

This method can be filtered.

Source

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

		$methods = [];

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

		foreach ($methods as $name => $method) {
			if ($options['strategies']) {
				$key = static::applyStrategies(__FUNCTION__, $name, $original, $options + [
					'key' => $key,
					'class' => __CLASS__
				]);
			}
			$params = compact('key', 'options');
			$result = Filters::run(get_called_class(), __FUNCTION__, $params, $method) || $result;
		}
		return $result;
	}