Jump to content

Manual:Hooks/WebResponseSetCookie

From mediawiki.org
WebResponseSetCookie
Available from version 1.22.0 (Gerrit change 78144)
Use to modify the cookie being set from WebResponse::setcookie().

Return false to prevent setting of the cookie.

Define function:
public static function onWebResponseSetCookie( string &$name, string &$value, int &$expire, array &$options ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"WebResponseSetCookie": "MediaWiki\\Extension\\MyExtension\\Hooks::onWebResponseSetCookie"
	}
}
Called from: File(s): WebResponse.php
Interface: WebResponseSetCookieHook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:WebResponseSetCookie extensions.


Details

[edit]
  • &$name: Cookie name passed to WebResponse::setcookie()
  • &$value: Cookie value passed to WebResponse::setcookie()
  • &$expire: Cookie expiration, as for PHP's setcookie()
  • &$options: Options passed to WebResponse::setcookie(). (This is only passed by reference after MediaWiki version 1.27)