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 = 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;
		};
	}