Manual:How to debug/Login problems/ja

ログインやセッションの問題 (ログインできない、すぐにログアウトしてしまう、ランダムにログアウトしてしまう、「セッション データの喪失」エラーで編集できないなど) は、多種多様な原因があるため、デバッグが困難です.

エラーを調査・報告する際の注意点を紹介します.



利用者向け

 * If the problem is being unable to login because of "There seems to be a problem with your login session..." errors, clearing all cookies for that site usually helps.
 * When making a bug report, always include what browser (and what version of it) you are using, whether you are using it in incognito mode, and whether you are using non-default privacy/security settings (such as "block third-party cookies").
 * If possible, include a precise date and time of when you experienced the problem, so it can be correlated with system logs.
 * You don't have to do an in-depth investigation just to file a bug report, but if you do want to, here are some kinds of information that are usually helpful:
 * ウィキ ドメインの Cookie を消去しても持続しますか? シークレット・モードでログインしても改善しませんか？ 別の種類のブラウザでログインしても改善しませんか？
 * 広告ブロックやブラウザのプライバシー設定を使用している場合、何かブロックされていませんか？ オフにしても改善しませんか？
 * 複数の利用者アカウントで起きますか? それとも 1 つの利用者アカウントのみですか?
 * Does the "remember me" flag make any difference? (Clear cookies before attempts.)
 * If the problems are happening on a Wikimedia wiki, try logging in on another wiki, preferably one that does not share a second-level domain name (so if the problem happens on xy.wikipedia.org, try for example xy.wiktionary.org).
 * If the above information is not enough to diagnose the issue (which is usually the case), you might be asked to get detailed debug data. For that, you need to capture the relevant HTTP requests and responses (i.e. visiting the login page + submitting the login form + the resulting redirect; if the wiki uses single sign-on then all the requests to  and   as well). This can be done by using the Network tab in the Developer Tools of your web browser (more information: Firefox; Internet Explorer, Chrome and Chromium, Safari). Dumping to a HAR file is an easy way to log all required data.
 * Note that this includes security-sensitive data (such as your session ID); when sharing the information as part of a bug report, you need to use a private paste. You are encouraged to remove your password from the report (in the case of a HAR file, you can just open it as a text file, search for the password and replace it with something else) and to log out and log back in afterwards.

For developers
When debugging the default MediaWiki login, look for the following things:
 * On Special:Userlogin, does the website set the  cookie? Is the cookie sent back correctly when the login form is submitted? Does the cookie value persist during multi-step login (e.g. 2FA)? Does the session exist in the backend (you can check with , using shell.php).
 * If you are debugging an API-based login, the cookie should instead be set by the response to  and returned in the   request. Clients failing to do this is the most common source of login errors. (Note that the best practice for bots and similar clients is to use owner-only consumers and not use login at all.)
 * After a successful login, are the,  ,  ,   cookies set (the last one only when the "keep logged in" checkbox was used)? Do the   /   /   fields match in the data stored in the backend? Does the token match the value of   in the database?
 * If you want to check things with a debugger like XDebug, for session/cookie problems the interesting parts tend to be the  method of the session provider (usually  ), and  . For problems with processig the submitted login request, it's   and the   and   methods of the primary authentication provider (by default  ). Note that these are pretty complex codebases and will be hard to understand if you aren't familiar with SessionManager and AuthManager.
 * See also the advice about logging in the next session.

When debugging CentralAuth (e.g. Wikimedia sites), the things to look for: There's an overview of CentralAuth authentication features available.
 * On top of the normal cookies, there should also be,   and (with the "keep logged in" option)   (typically set on the parent domain). These should be enough to recreate the other cookies when those are missing. The session cookie corresponds to the central session; its data can be checked with   (using shell.php). The token corresponds to   in CentralAuth's shared database.
 * After a successful login, there should be a chain of redirects to  →   → back to the initial page (or   target). The /start step sets up a stub central session, and sets cookies for the central domain; the /complete step finalizes the central session, and sets cookies for the local domain. (See phpdoc in   for a more detailed description.) Are the cookies emitted as expected? Does the browser actually persist them? Is the data stored in the central session backend correct? If this step doesn't work, edge login / autologin won't work either.
 * The "keep logged in" flag (ie. the  cookie) is set in a separate step, by a request to Special:CentralAutoLogin/refreshCookies that's triggered from an  tag when the rest of the autologin is finished. Are the cookies emitted? Does the browser actually persist them? When this step doesn't work, edge login / autologin will stop working when the central session expires in a day or so.
 * Right after central login, edge login is triggered: For every wiki in, there is a redirect chain to various Special:CentralAutologin subpages (/start → /checkLoggedIn → /createSession → /validateSession → /setCookies) via an image embedded in the page. The setCookies step should create a local session and set the session cookies. Are the cookies emitted? Does the browser actually persist them?
 * When visiting a wiki where you do not have an active session (and no shared cookies on the parent domain to create one), central autologin is triggered. This is basically the same as edge login, just in a script tag instead of an image tag, and the same things should be verified.
 * When central autologin fails, further attempts are prevented by setting the  localStorage flag; you might need to clear that when testing.
 * When visiting the login page while not having an active session, top-level autologin is triggered. This is basically the same as normal autologin, just with the whole page being redirected, instead of an embedded image doing the redirects, and the same things should be verified.

For site administrators

 * Check what session backend is being used, and make sure it works (data is actually persisted between requests). The most safe configuration is . If you're unsure about how it's configured, add this setting at the end of your LocalSettings.php.
 * Be sure is not set to 1 or true, otherwise PHP sessions will overwrite MediaWiki sessions.
 * Be sure is set to an empty string. It marks sessions as invalid if configured incorrectly.
 * If set, be sure and  are correct.
 * If is set to true, your webserver must be served with HTTPS.
 * Ensure the hostnames match in MediaWiki and Apache . For example, for the domain   and the web server located at  :
 * And:
 * If you use an ancient MediaWiki version (older than 1.27), check the value of ; if it is false, test that your PHP session handling is working (e.g. that  is writable).
 * If you file a bug report:
 * Report what MediaWiki version you use and what session providers you are using (the value of ).
 * Check your logs for relevant records, especially the,  ,  , ,   channels (besides the usual  ,  ,  ). Also   if your are looking into CAPTCHA issues, and   if you are using that extension.
 * For certain types of cache you can get more information by setting debug mode:
 * Please do not reuse old bug reports unless you are sure it's the same cause. There are lots of reports about past issues, and the while symptoms will usually look vaguely similar to yours (there are only so many ways login can fail) the cause is likely to be different.
 * For certain types of cache you can get more information by setting debug mode:
 * Please do not reuse old bug reports unless you are sure it's the same cause. There are lots of reports about past issues, and the while symptoms will usually look vaguely similar to yours (there are only so many ways login can fail) the cause is likely to be different.
 * Please do not reuse old bug reports unless you are sure it's the same cause. There are lots of reports about past issues, and the while symptoms will usually look vaguely similar to yours (there are only so many ways login can fail) the cause is likely to be different.