Can you force (or at least prompt) new users to keep themselves logged in?

In order to reduce the likelihood of losing work, I would like the Special:UserLogin page to appear as enter image description here


You can probably use $wgDefaultUserOptions['rememberpassword'] = 1. See $wgDefaultUserOptions (and also $wgHiddenPrefs).


(MediaWiki 1.31.0) Add to LocalSettings.php:

$wgHooks['AuthChangeFormFields'][] = function ($requests, $fieldInfo, &$formDescriptor, $action) {
  $formDescriptor['rememberMe']['default'] = true;
  return true;

See Hooks/AuthChangeFormFields and HTMLForm.

  • That looks like it might work. Where did you get this code? Can you link to a source or to documentation from which you pieced to together? – Stephen Ostermiller Jul 4 '18 at 16:53

The above answer will now throw fatal exception on Special:CreateAccount if anybody attempts account creation. You have to define the HTML form class. Something like this:

// Check the password "remember me" box by default (sitewide)
$wgHooks['AuthChangeFormFields'][] = function ($requests, $fieldInfo, &$formDescriptor, $action) {
    $formDescriptor['rememberMe'] = ['type' => 'check', 'default' => true ];
    return true;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.