Manual:Hooks/UserSetCookies

From MediaWiki.org
Jump to navigation Jump to search
UserSetCookies
Available from version 1.13.0
Called when setting user cookies
Define function:
public static function onUserSetCookies( $user, &$session, &$cookies ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"UserSetCookies": "MyExtensionHooks::onUserSetCookies"
	}
}

For MediaWiki ≤1.25:

$wgHooks['UserSetCookies'][] = 'MyExtensionHooks::onUserSetCookies';
Called from:File(s): User.php

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

Details[edit]

  • $user: User object
  • &$session: session array, will be added to $_SESSION
  • &$cookies: cookies array mapping cookie name to its value