Opened 15 years ago
Closed 12 years ago
#15318 closed New feature (fixed)
A possibility to configure the language's cookie domain and expires.
| Reported by: | sahid | Owned by: | Sergey Kolosov |
|---|---|---|---|
| Component: | Internationalization | Version: | 1.2 |
| Severity: | Normal | Keywords: | cookie, domain, language, settings |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Hello,
A suggest a new settings: LANGUAGE_COOKIE_DOMAIN
Index: conf/global_settings.py
===================================================================
--- conf/global_settings.py (revision 15552)
+++ conf/global_settings.py (working copy)
@@ -112,6 +112,8 @@
USE_I18N = True
LOCALE_PATHS = ()
LANGUAGE_COOKIE_NAME = 'django_language'
+LANGUAGE_COOKIE_DOMAIN = None
+LANGUAGE_COOKIE_EXPIRES = None
# If you set this to True, Django will format dates, numbers and calendars
# according to user current locale
Index: views/i18n.py
===================================================================
--- views/i18n.py (revision 15552)
+++ views/i18n.py (working copy)
@@ -32,7 +32,11 @@
if hasattr(request, 'session'):
request.session['django_language'] = lang_code
else:
- response.set_cookie(settings.LANGUAGE_COOKIE_NAME, lang_code)
+ response.set_cookie(
+ settings.LANGUAGE_COOKIE_NAME,
+ lang_code,
+ expires=settings.LANGUAGE_COOKIE_EXPIRES,
+ domain=settings.LANGUAGE_COOKIE_DOMAIN)
return response
def get_formats():
Change History (11)
comment:1 by , 15 years ago
| Needs tests: | set |
|---|---|
| Patch needs improvement: | set |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 15 years ago
| Component: | Translations → Internationalization |
|---|
comment:3 by , 15 years ago
| Severity: | → Normal |
|---|---|
| Type: | → New feature |
comment:6 by , 12 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:7 by , 12 years ago
| Needs tests: | unset |
|---|---|
| Patch needs improvement: | unset |
Pull request: https://github.com/django/django/pull/1150
For the sake of consistency I've added the following settings: LANGUAGE_COOKIE_AGE, LANGUAGE_COOKIE_PATH and LANGUAGE_COOKIE_DOMAIN.
comment:8 by , 12 years ago
This could be solved without introducing additional top-level settings if/after #21051 lands.
comment:9 by , 12 years ago
| Patch needs improvement: | set |
|---|
I've left comments for improvement on the PR. Please uncheck "Patch needs improvement" when it's updated.
comment:10 by , 12 years ago
| Patch needs improvement: | unset |
|---|
Pull request is updated: https://github.com/django/django/pull/1150
comment:11 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Patch needs to be attached as a diff, rather than as a comment. It also requires tests.