lithium\storage\session\adapter\Cookie::clear()

public method

Clears all cookies.

Parameters

  • array $options

    Options array. Not used fro this adapter method.

Returns

boolean

True on successful clear, false otherwise.

Source

	public function clear(array $options = []) {
		$options += ['destroySession' => true];
		$cookieClass = get_called_class();

		return function($params) use ($options, $cookieClass) {
			if ($options['destroySession'] && session_id()) {
				session_destroy();
			}
			if (!isset($_COOKIE[$this->_config['name']])) {
				return true;
			}
			$cookies = array_keys(Set::flatten($_COOKIE[$this->_config['name']]));
			foreach ($cookies as $name) {
				$result = setcookie(
					$cookieClass::keyFormat($name, $this->_config),
					"",
					1,
					$this->_config['path'],
					$this->_config['domain'],
					$this->_config['secure'],
					$this->_config['httponly']
				);
				if (!$result) {
					throw new RuntimeException("There was an error clearing {$cookie} cookie.");
				}
			}
			unset($_COOKIE[$this->_config['name']]);
			return true;
		};
	}