lithium\storage\session\adapter\Cookie::clear PHP Method

clear() public method

Clears all cookies.
public clear ( array $options = [] ) : boolean
$options array Options array. Not used fro this adapter method.
return boolean True on successful clear, false otherwise.
    public function clear(array $options = array())
    {
        $options += array('destroySession' => true);
        $config = $this->_config;
        $cookieClass = get_called_class();
        return function ($self, $params) use(&$config, $options, $cookieClass) {
            if ($options['destroySession'] && session_id()) {
                session_destroy();
            }
            if (!isset($_COOKIE[$config['name']])) {
                return true;
            }
            $cookies = array_keys(Set::flatten($_COOKIE[$config['name']]));
            foreach ($cookies as $name) {
                $name = $cookieClass::keyFormat($name, $config);
                $result = setcookie($name, "", 1, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
                if (!$result) {
                    throw new RuntimeException("There was an error clearing {$cookie} cookie.");
                }
            }
            unset($_COOKIE[$config['name']]);
            return true;
        };
    }