From eaf5dabf88a4f5d6cfec98c3922c06dc70e8110c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerg=C5=91=20Tisza?= Date: Tue, 3 Nov 2015 00:45:41 -0800 Subject: [PATCH] Add WebResponse::clearCookie() Easier-to-read alias for setCookie(..., '', time() - 86400). Change-Id: I0357c4a38085c4754bf6ff7e40756179d19b912d --- includes/WebResponse.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 ); + } } /** -- 2.20.1