aboutsummaryrefslogtreecommitdiffstats
path: root/includes/WebResponse.php
diff options
context:
space:
mode:
authorGergő Tisza <tgr.huwiki@gmail.com>2015-11-03 00:45:41 -0800
committerAnomie <bjorsch@wikimedia.org>2015-11-03 20:14:33 +0000
commiteaf5dabf88a4f5d6cfec98c3922c06dc70e8110c (patch)
tree641216f1d706703417ae8e94dbe57282844a3fdc /includes/WebResponse.php
parent5def88354828f40548a6330077064876b5dbd1a8 (diff)
downloadmediawikicore-eaf5dabf88a4f5d6cfec98c3922c06dc70e8110c.tar.gz
mediawikicore-eaf5dabf88a4f5d6cfec98c3922c06dc70e8110c.zip
Add WebResponse::clearCookie()
Easier-to-read alias for setCookie(..., '', time() - 86400). Change-Id: I0357c4a38085c4754bf6ff7e40756179d19b912d
Diffstat (limited to 'includes/WebResponse.php')
-rw-r--r--includes/WebResponse.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/includes/WebResponse.php b/includes/WebResponse.php
index bb7682d3e832..26fb20f331b2 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 );
+ }
}
/**