lithium\storage\Session::delete()
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 totrue
.
Returns
booleanReturns 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;
$options += ['key' => $key, 'class' => __CLASS__];
$original = $key;
foreach ($methods as $name => $method) {
$settings = static::_config($name);
if ($options['strategies']) {
$options += ['key' => $key, 'class' => __CLASS__];
$key = static::applyStrategies(__FUNCTION__, $name, $original, $options);
}
$params = compact('key', 'options');
if (!empty($settings['filters'])) {
$message = 'Per adapter filters have been deprecated. Please ';
$message .= "filter the manager class' static methods instead.";
trigger_error($message, E_USER_DEPRECATED);
$result = Filters::bcRun(
get_called_class(), __FUNCTION__, $params, $method, $settings['filters']
) || $result;
} else {
$result = Filters::run(get_called_class(), __FUNCTION__, $params, $method) || $result;
}
}
return $result;
}