Add getCookie(). Stuff should use this now instead of accessing $_COOKIE directly
authorChad Horohoe <demon@users.mediawiki.org>
Wed, 26 May 2010 00:50:46 +0000 (00:50 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Wed, 26 May 2010 00:50:46 +0000 (00:50 +0000)
includes/WebRequest.php

index 834f2b1..83f9690 100644 (file)
@@ -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 <type>
+        */
+       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