From: Gergő Tisza Date: Tue, 3 Nov 2015 08:45:41 +0000 (-0800) Subject: Add WebResponse::clearCookie() X-Git-Tag: 1.31.0-rc.0~9119^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles_versions%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=eaf5dabf88a4f5d6cfec98c3922c06dc70e8110c;p=lhc%2Fweb%2Fwiklou.git Add WebResponse::clearCookie() Easier-to-read alias for setCookie(..., '', time() - 86400). Change-Id: I0357c4a38085c4754bf6ff7e40756179d19b912d --- diff --git a/includes/WebResponse.php b/includes/WebResponse.php index bb7682d3e8..26fb20f331 100644 --- a/includes/WebResponse.php +++ b/includes/WebResponse.php @@ -136,6 +136,19 @@ class WebResponse { $options['httpOnly'] ); } } + + /** + * Unset a browser cookie. + * This sets the cookie with an empty value and an expiry set to a time in the past, + * which will cause the browser to remove any cookie with the given name, domain and + * path from its cookie store. Options other than these (and prefix) have no effect. + * @param string $name Cookie name + * @param array $options Cookie options, see {@link setCookie()} + * @since 1.27 + */ + public function clearCookie( $name, $options = array() ) { + $this->setCookie( $name, '', time() - 31536000 /* 1 year */, $options ); + } } /**