Skip to content

Commit c78f86e

Browse files
authored
Improve documentation for session_cookie_domain with IDN (umlaut) domains (#566)
* Update session_cookie_domain documentation Add important notes and recommendations for using session_cookie_domain with IDN domains. * Обновить раздел о session_cookie_domain для IDN Добавлены рекомендации по использованию настройки session_cookie_domain с международными доменными именами (IDN), включая примеры и поведение при различных конфигурациях. * Update default value for session_cookie_domain Changed default value for session_cookie_domain from 'localhost' to '' and updated the description. * Change default session cookie domain to empty string Updated the default value of the session cookie domain from 'localhost' to an empty string. * Update session_cookie_domain documentation with recommendations Added recommendations for using session_cookie_domain with IDN domains and clarified behavior in testing. * Update session_cookie_domain.md with recommendations Added recommendations for handling session cookie domains, including the use of punycode for IDN domains and the behavior of different domain types.
1 parent 61f88cf commit c78f86e

2 files changed

Lines changed: 54 additions & 6 deletions

File tree

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
title: "session_cookie_domain"
3-
_old_id: "276"
4-
_old_uri: "2.x/administering-your-site/settings/system-settings/session_cookie_domain"
3+
description: "Session Cookie Domain setting"
4+
55
---
66

77
## session\_cookie\_domain
88

9-
**Name**: Session Cookie Domain
10-
**Type**: String
11-
**Default**: localhost
9+
- **Name**: Session Cookie Domain
10+
- **Type**: String
11+
- **Default**: ''
1212

1313
Use this setting to customize the session cookie domain.
1414

@@ -21,3 +21,27 @@ This setting is useful to change if you are running multiple Contexts on one top
2121
will allow all MODX sessions to persist across any \*.mydomain.com site, allowing logins to work across subdomains.
2222

2323
This setting isn't in MODX by default, as it's best to let PHP calculate this on its own. Only set this if you are sure of what you are doing.
24+
25+
### Important note for IDN (internationalized) domains
26+
27+
When using the `session_cookie_domain` setting with internationalized domain names (IDN), such as domains containing umlauts (e.g. `müller-example.de`), session handling may fail depending on the server and PHP configuration.
28+
29+
HTTP cookies (including session cookies) are based on ASCII-compatible domain names. In practice, this means that IDN domains are typically represented in **punycode (A-label)** form when used at the protocol level.
30+
31+
Example:
32+
33+
- Unicode: `müller-example.de`
34+
- Punycode: `xn--mller-example-9db.de`
35+
36+
In testing, the following behavior was observed:
37+
38+
- ASCII domain - works as expected
39+
- Unicode IDN domain in `session_cookie_domain` - may break sessions
40+
- Empty `session_cookie_domain` - works reliably
41+
42+
**Recommendations:**
43+
44+
- Avoid setting `session_cookie_domain` unless explicitly required, leave it empty to let PHP handle it automatically
45+
- If using IDN domains, prefer the punycode (ASCII) representation
46+
47+
Note: Behavior may vary depending on PHP version, browser, and server configuration.

ru/building-sites/settings/session_cookie_domain.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ translation: "building-sites/settings/session_cookie_domain"
77

88
- **Имя**: Домен для сессионных куки
99
- **Тип**: String
10-
- **По умолчанию**: localhost
10+
- **По умолчанию**: ''
1111

1212
Используйте этот параметр для настройки домена cookie сеанса.
1313
Вам нужно будет очистить локальные куки в вашем браузере после изменения этого параметра.
@@ -17,3 +17,27 @@ translation: "building-sites/settings/session_cookie_domain"
1717
1818
Позволит всем сеансам MODX сохраняться на любом сайте \*.mydomain.com, позволяя логинам работать на поддоменах.
1919
Этот параметр по умолчанию отсутствует в MODX, так как лучше позволить PHP рассчитать его самостоятельно. Установите это, только если вы уверены, что делаете.
20+
21+
### Важное замечание для IDN-доменов (международных доменных имён)
22+
23+
При использовании настройки `session_cookie_domain` с международными доменными именами (IDN), например с доменами, содержащими umlaut (например, `müller-example.de`), работа сессий может нарушаться в зависимости от конфигурации сервера и PHP.
24+
25+
HTTP cookies (включая сессионные cookies) основаны на ASCII-совместимых доменных именах. На практике это означает, что IDN-домены обычно представляются в виде **punycode (A-label)** при использовании на уровне протокола.
26+
27+
Пример:
28+
29+
- Unicode: `müller-example.de`
30+
- Punycode: `xn--mller-example-9db.de`
31+
32+
В ходе тестирования наблюдалось следующее поведение:
33+
34+
- ASCII-домен - работает корректно
35+
- Unicode IDN-домен в `session_cookie_domain` - может приводить к сбоям сессий
36+
- Пустое значение `session_cookie_domain` - работает стабильно
37+
38+
**Рекомендации:**
39+
40+
- Не задавайте `session_cookie_domain`, если в этом нет явной необходимости, оставьте значение пустым, чтобы PHP автоматически обработал домен
41+
- При использовании IDN-доменов предпочтительно использовать представление в punycode (ASCII)
42+
43+
Примечание: поведение может отличаться в зависимости от версии PHP, браузера и конфигурации сервера.

0 commit comments

Comments
 (0)