Extension:CookieWarning

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
Crystal Clear action run.svg
CookieWarning
Release status: stable
Implementation User interface
Description Adds a notice to the top of the page, that informs the user, that this wiki uses cookies to operate.
Author(s)
Latest version 0.2.0 (2016-09-29)
MediaWiki 1.25+
PHP 5.4+
Database changes No
License MIT License
Download
Example DroidWiki.de
Parameters
  • $wgCookieWarningEnabled
  • $wgCookieWarningMoreUrl
  • $wgCookieWarningGeoIPServiceURL
  • $wgCookieWarningGeoIPLookup
  • $wgCookieWarningForCountryCodes
Hooks used
SkinTemplateOutputPageBeforeExec
BeforePageDisplay
GetPreferences
ResourceLoaderGetConfigVars
BeforeInitialize
Translate the CookieWarning extension if it is available at translatewiki.net
Check usage and version matrix.
Issues Open tasks · Report a bug

The CookieWarning extension is a small and simple extension that adds a small but well-visible information banner to your wiki, which informs users that the wiki uses cookies to operate properly. The default message also includes a sentence that the user, if they continue to use the wiki, agrees to the wiki's use of cookies.

Background[edit]

In some countries it's requires by law (e.g. in the European Union) that you, as a website operator, ask your users for permission to use cookies with your website. In the EU, some of your partners may require you to ask your users to use cookies (e.g. because you use Google AdSense, which requires this notice[1]). To make it easier for wiki administartors to implement these notices, this extension was created (by Florianschmidtwelzow, primarily for use on droidwiki.de).

History[edit]

This extension was merged with the former CookiePolicy extension, which provided a similar functionality and was originally written by Liz Lee for Wikia and further cleaned up and enhanced by Jack Phoenix for ShoutWiki.

Installation[edit]

  • Download and place the file(s) in a directory called CookieWarning in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'CookieWarning' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration[edit]

After the successful installation of CookieWarning, you need to enable it with the configuration option $wgCookieWarningEnabled, which you need to set to true in your "LocalSettings.php". If you have a page, where you explain how you and your partners use cookies in your wiki, you may want to link to this page. For this, you can add another configuration option, $wgCookieWarningMoreUrl, which simply takes the URL of the page (full or relative, but relative may not work, if you use subpages in your wiki!). Alternatively you can set [[MediaWiki:Cookiewarning-more-link]] to the URL of your site's privacy policy or similar page which explains about cookies.

Configuration parameters[edit]

There're some other configurations, that can help you to target the correct users with the cookie information bar. The the following table contains all possible options.

Configuration Default value Description
$wgCookieWarningEnabled false You have to set this variable to 'true' to make the extension work.
$wgCookieWarningMoreUrl none Set the URL to your 'More Information' page.
$wgCookieWarningGeoIPServiceURL //freegeoip.net/json/ An IP location service, which takes the IP address of the visitor and returns a JSON string that complies to the freegeoip.net schema (example). CAUTION: If the geo-targeting is enabled, the IP address of your users will be directly (NOT anonymized!) sent to the service configured in this option, which may be a problem in some countries or jurisdictions.
$wgCookieWarningGeoIPLookup none When and how do you want that the wiki tries to locate the user. Possible values:
  • none: The geo-targeting is turned off and the extension will not try to locate the user based on the IP address.
  • php: The extension ships with a class that handles to request the service configured in wgCookieWarningGeoIPServiceURL to locate the user. The request timeout is 2 seconds, so depending on the connection of your server and the load of the configured service, this may slow down the request for the user. However, locating the user will work, even if the user has turned off JavaScript.
  • js: The extension will ship a client side JavaScript code to the user with each request, which will try to locate the user (again, using the service configured in $wgCookieWarningGeoIPServiceURL). The size of the shipped page will increase accordingly, however, the processing of the request does not depend on a third-party site anymore (like when using php).
$wgCookieWarningForCountryCodes

[
"EU" => "Europe",
"AD" => "Andorra",
"AL" => "Albania",
"AT" => "Austria",
"BA" => "Bosnia and Herzegovina",
"BE" => "Belgium",
"BG" => "Bulgaria",
"BY" => "Belarus",
"CH" => "Switzerland",
"CS" => "Serbia and Montenegro",
"CZ" => "Czech Republic",
"DE" => "Germany",
"DK" => "Denmark",
"EE" => "Estonia",
"ES" => "Spain",
"FI" => "Finland",
"FO" => "Faroe Islands",
"FR" => "France",
"FX" => "France, Metropolitan",
"GB" => "United Kingdom",
"GI" => "Gibraltar",
"GR" => "Greece",
"HR" => "Croatia",
"HU" => "Hungary",
"IE" => "Ireland",
"IS" => "Iceland",
"IT" => "Italy",
"LI" => "Liechtenstein",
"LT" => "Lithuania",
"LU" => "Luxembourg",
"LV" => "Latvia",
"MC" => "Monaco",
"MD" => "Moldova, Republic of",
"MK" => "Macedonia",
"MT" => "Malta",
"NL" => "Netherlands",
"NO" => "Norway",
"PL" => "Poland",
"PT" => "Portugal",
"RO" => "Romania",
"SE" => "Sweden",
"SI" => "Slovenia",
"SJ" => "Svalbard and Jan Mayen",
"SK" => "Slovakia",
"SM" => "San Marino",
"UA" => "Ukraine",
"VA" => "Holy See (Vatican City State)",
]

The list of regions, which users should see the cookie notification bar.

System messages[edit]

If you would like to change the text of the messages shown navigate to the following pages and adjust as required:

  • "MediaWiki:Cookiewarning-info"
  • "MediaWiki:Cookiewarning-moreinfo-label"
  • "MediaWiki:Cookiewarning-more-link"
  • "MediaWiki:Cookiewarning-ok-label"

Migrating from CookiePolicy extension[edit]

In October 2016, the CookiePolicy extension was merged into the CookieWarning extension, as both tried to solve the same problem. The following sections will give you the information, what you need to do to migrate CookiePolicy to CookieWarning.

[[MediaWiki:Cookie-policy-link]][edit]

The [[MediaWiki:Cookie-policy-link]] interface message will be observed by CookieWarning, too, so you can use your customization of the message shown to the user with CookieWarning, too. However, as this is just for backwards compatibility reasons, it's strongly recommended to change to the CookieWarning message [[MediaWiki:Cookiewarning-more-link]], e.g. by moving the page on your wiki, or using the configuration option $wgCookieWarningMoreUrl to configure the target link.

JavaScript based geo-targeting[edit]

The logic to locate an user used in CookiePolicy was merged into CookieWarning. However you need to configure some things to enable it by setting the following options into your LocalSettings.php:

$wgCookieWarningEnabled = true;
$wgCookieWarningGeoIPLookup = 'js';

$wgCookiePolicyGeoIPServiceURL[edit]

The $wgCookiePolicyGeoIPServiceURL configuration option is named $wgCookieWarningGeoIPServiceURL in CookieWarning, you need to change it in your LocalSettings.php, if you use it.

It's too simple! I need help! (aka I found a bug, what should I do?)[edit]

You can always request help and report problems on the talk page or at Phabricator.

References[edit]