Opened 8 years ago

Closed 5 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



A suggest a new settings: LANGUAGE_COOKIE_DOMAIN

Index: conf/
--- conf/	(revision 15552)
+++ conf/	(working copy)
@@ -112,6 +112,8 @@
 USE_I18N = True
 LANGUAGE_COOKIE_NAME = 'django_language'
 # If you set this to True, Django will format dates, numbers and calendars
 # according to user current locale
Index: views/
--- views/	(revision 15552)
+++ views/	(working copy)
@@ -32,7 +32,11 @@
             if hasattr(request, 'session'):
                 request.session['django_language'] = lang_code
-                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 Changed 8 years ago by Russell Keith-Magee

Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

Patch needs to be attached as a diff, rather than as a comment. It also requires tests.

comment:2 Changed 8 years ago by Ramiro Morales

Component: TranslationsInternationalization

comment:3 Changed 8 years ago by Łukasz Rekucki

Severity: Normal
Type: New feature

comment:4 Changed 7 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 Changed 7 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 Changed 5 years ago by Sergey Kolosov

Owner: changed from nobody to Sergey Kolosov
Status: newassigned

comment:7 Changed 5 years ago by Sergey Kolosov

Needs tests: unset
Patch needs improvement: unset

Pull request:

For the sake of consistency I've added the following settings: LANGUAGE_COOKIE_AGE, LANGUAGE_COOKIE_PATH and LANGUAGE_COOKIE_DOMAIN.

comment:8 Changed 5 years ago by Ramiro Morales

This could be solved without introducing additional top-level settings if/after #21051 lands.

comment:9 Changed 5 years ago by Tim Graham

Patch needs improvement: set

I've left comments for improvement on the PR. Please uncheck "Patch needs improvement" when it's updated.

comment:10 Changed 5 years ago by Sergey Kolosov

Patch needs improvement: unset

comment:11 Changed 5 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 8c98f39624a60c63a16e097b64e5f71ecc27271f:

Fixed #15318 -- Added settings for language cookie max-age, path, domain

Introduced a number of settings to configure max-age, path, and domain
for the language cookie: LANGUAGE_COOKIE_AGE, LANGUAGE_COOKIE_PATH and

Thanks sahid for the suggestion.

Note: See TracTickets for help on using tickets.
Back to Top