/** * Deletes a cookie with the given name. * * @param string $name * @param CookieMetadata $metadata * @return void * @throws FailureToSendException If cookie couldn't be sent to the browser. * If this exception isn't thrown, there is still no guarantee that the browser * received and accepted the request to delete this cookie. * @throws InputException If the cookie name is empty or contains invalid characters. */ public function deleteCookie($name, CookieMetadata $metadata = null) { $metadataArray = $this->scope->getCookieMetadata($metadata)->__toArray(); // explicitly set an expiration time in the metadataArray. $metadataArray[PhpCookieManager::KEY_EXPIRE_TIME] = PhpCookieManager::EXPIRE_NOW_TIME; $this->checkAbilityToSendCookie($name, ''); // cookie value set to empty string to delete from the remote client $this->setCookie($name, '', $metadataArray); // Remove the cookie unset($_COOKIE[$name]); }