lithium\storage\Session::delete PHP Method

delete() public static method

Deletes a named key from a single adapter (if a 'name' option is specified) or all session adapters.
public static delete ( string $key, array $options = [] ) : boolean
$key string The name of the session key to delete.
$options array 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`.
return boolean Returns `true` on successful delete, or `false` on failure.
    public static function delete($key, array $options = array())
    {
        $defaults = array('name' => null, 'strategies' => true);
        $options += $defaults;
        $methods = array();
        if ($name = $options['name']) {
            $methods = array($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 += array('key' => $key, 'class' => __CLASS__);
        $original = $key;
        foreach ($methods as $name => $method) {
            $settings = static::_config($name);
            if ($options['strategies']) {
                $options += array('key' => $key, 'class' => __CLASS__);
                $key = static::applyStrategies(__FUNCTION__, $name, $original, $options);
            }
            $params = compact('key', 'options');
            $filters = $settings['filters'];
            $result = static::_filter(__FUNCTION__, $params, $method, $filters) || $result;
        }
        return $result;
    }

Usage Example

 public function success()
 {
     $code = $this->request->query['code'];
     $access = Consumer::token('access', compact('code') + array('params' => array('redirect_uri' => Consumer::serviceConfig('success'))));
     Session::delete('oauth.access');
     Session::write('oauth.access', $access);
     $this->redirect('Facebook::feed');
 }
All Usage Examples Of lithium\storage\Session::delete