From 8da9785fc96230efabbd8308c232e0f9f732a3cb Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 26 May 2010 00:50:46 +0000 Subject: [PATCH] Add getCookie(). Stuff should use this now instead of accessing $_COOKIE directly --- includes/WebRequest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 834f2b1e77..83f9690d00 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -431,6 +431,21 @@ class WebRequest { return isset( $_COOKIE[session_name()] ); } + /** + * Get a cookie from the $_COOKIE jar + * @param String $key The name of the cookie + * @param mixed $default What to return if the value isn't found + * @param String $prefix A prefix to use for the cookie name, if not $wgCookiePrefix + * @return + */ + public function getCookie( $key, $default = null, $prefix = '' ) { + if( !$prefix ) { + global $wgCookiePrefix; + $prefix = $wgCookiePrefix; + } + return $this->getGPCVal( $_COOKIE, $prefix . $key , $default ); + } + /** * Return the path portion of the request URI. * @return string -- 2.20.1