[GH-ISSUE #4919] [Bug]: After some time, the language changes to the system language #3440

Closed
opened 2026-10-31 20:32:27 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @smalbord on GitHub (Jun 4, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4919

Describe the bug

The system language is Russian, and the login page is initially displayed in Russian. I select English, log in, do whatever I need to in the control panel, log out, and close the browser. After a short while, I return to the login page, and the system language is again set to Russian, instead of English. On version 2.8.X, the language setting remained unchanged, no matter how long I waited to log in to the control panel.

In DevTools, the cookie is shown as a session cookie. This might be the issue.

How to reproduce the problem

  1. Open the login page.
  2. Change the language to anything other than the system language.
  3. Log in.
  4. Log out.
  5. Close the browser.
  6. Wait for a while, for example, 1-2 hours, or possibly longer.
  7. Open the login page.
  8. The language should reset from the previously selected one to the system language.

Expected behavior

The selected language should remain the same for a long time, as it was in version 2.8.X.

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.2.7

Xray-core version

26.6.1

How did you install 3x-ui?

Docker / Docker Compose

Operating system

Ubuntu 24.04

Which parts of the panel are affected?

No response

Browser (only if it is a UI bug)

Firefox 151

Is the panel behind a reverse proxy or CDN?

Yes — Nginx

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @smalbord on GitHub (Jun 4, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4919 ### Describe the bug The system language is Russian, and the login page is initially displayed in Russian. I select English, log in, do whatever I need to in the control panel, log out, and close the browser. After a short while, I return to the login page, and the system language is again set to Russian, instead of English. On version 2.8.X, the language setting remained unchanged, no matter how long I waited to log in to the control panel. In DevTools, the cookie is shown as a session cookie. This might be the issue. ### How to reproduce the problem 1. Open the login page. 2. Change the language to anything other than the system language. 3. Log in. 4. Log out. 5. Close the browser. 6. Wait for a while, for example, 1-2 hours, or possibly longer. 7. Open the login page. 8. The language should reset from the previously selected one to the system language. ### Expected behavior The selected language should remain the same for a long time, as it was in version 2.8.X. ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.2.7 ### Xray-core version 26.6.1 ### How did you install 3x-ui? Docker / Docker Compose ### Operating system Ubuntu 24.04 ### Which parts of the panel are affected? _No response_ ### Browser (only if it is a UI bug) Firefox 151 ### Is the panel behind a reverse proxy or CDN? Yes — Nginx ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:32:27 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jun 4, 2026):

Root cause confirmed

Your DevTools observation is exactly right — the lang cookie is set as a session cookie (no expiry). That is a bug in the current frontend code.

Where the bug is: frontend/src/utils/index.ts, LanguageManager.setLanguage() (line ~874):

static setLanguage(language: string): void {
  // ...
  CookieManager.setCookie('lang', language);  // ← no exdays argument → session cookie
  window.location.reload();
}

CookieManager.setCookie only writes an expires attribute when the exdays argument is provided:

static setCookie(cname: string, cvalue: string, exdays?: number): void {
  let expires = '';
  if (exdays) {   // undefined → falsy → no expires written
    // ...
  }
  document.cookie = cname + '=' + encodeURIComponent(cvalue) + ';' + expires + 'path=/';
}

Without expires (or Max-Age) the browser treats the cookie as a session cookie and discards it when the browser is closed. The next visit falls back to navigator.language (Russian in your case), so the panel reverts to Russian.

The same missing exdays applies inside LanguageManager.getLanguage() when it auto-detects and caches the browser language, so the auto-detected cookie is also a session cookie.

The fix is to pass an expiry (e.g. 365 days) wherever the lang cookie is written:

CookieManager.setCookie('lang', language, 365);

This is a regression introduced with the new React frontend (the old pre-React code presumably used a persistent cookie or localStorage).


Workaround until a fix is released: You can manually set the cookie with an expiry in Firefox DevTools:

  1. Open DevTools → Storage → Cookies → select your panel's domain.
  2. Find the lang cookie and set its Expires column to a date far in the future (e.g. 2027-01-01).
  3. The panel will remember English across browser restarts.

Related closed issue: #4588 (same root cause, reported there as an enhancement request but it is clearly a regression).

<!-- gh-comment-id:4624157581 --> @github-actions[bot] commented on GitHub (Jun 4, 2026): ## Root cause confirmed Your DevTools observation is exactly right — the `lang` cookie is set as a **session cookie** (no expiry). That is a bug in the current frontend code. **Where the bug is:** `frontend/src/utils/index.ts`, `LanguageManager.setLanguage()` (line ~874): ```ts static setLanguage(language: string): void { // ... CookieManager.setCookie('lang', language); // ← no exdays argument → session cookie window.location.reload(); } ``` `CookieManager.setCookie` only writes an `expires` attribute when the `exdays` argument is provided: ```ts static setCookie(cname: string, cvalue: string, exdays?: number): void { let expires = ''; if (exdays) { // undefined → falsy → no expires written // ... } document.cookie = cname + '=' + encodeURIComponent(cvalue) + ';' + expires + 'path=/'; } ``` Without `expires` (or `Max-Age`) the browser treats the cookie as a session cookie and discards it when the browser is closed. The next visit falls back to `navigator.language` (Russian in your case), so the panel reverts to Russian. The same missing `exdays` applies inside `LanguageManager.getLanguage()` when it auto-detects and caches the browser language, so the auto-detected cookie is also a session cookie. **The fix** is to pass an expiry (e.g. 365 days) wherever the `lang` cookie is written: ```ts CookieManager.setCookie('lang', language, 365); ``` This is a regression introduced with the new React frontend (the old pre-React code presumably used a persistent cookie or `localStorage`). --- **Workaround until a fix is released:** You can manually set the cookie with an expiry in Firefox DevTools: 1. Open DevTools → Storage → Cookies → select your panel's domain. 2. Find the `lang` cookie and set its **Expires** column to a date far in the future (e.g. 2027-01-01). 3. The panel will remember English across browser restarts. Related closed issue: #4588 (same root cause, reported there as an enhancement request but it is clearly a regression).
Author
Owner

@Ramazik commented on GitHub (Jun 4, 2026):

A pull request was previously proposed to resolve this issue: https://github.com/MHSanaei/3x-ui/pull/4890

<!-- gh-comment-id:4625083392 --> @Ramazik commented on GitHub (Jun 4, 2026): A pull request was previously proposed to resolve this issue: https://github.com/MHSanaei/3x-ui/pull/4890
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3440
No description provided.