Skip to content

Instantly share code, notes, and snippets.

@makerj
Last active December 30, 2020 19:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makerj/295ea3d2160326694c123bd8db164d9b to your computer and use it in GitHub Desktop.
Save makerj/295ea3d2160326694c123bd8db164d9b to your computer and use it in GitHub Desktop.
HOW TO SHARE COOKIE ACROSS SUBDOMAINS IN DJANGO
"""
PRODUCTION SETTINGS AREA
"""
if not DEBUG:
# share cookie across sub-domains. LEADING DOT IN DOMAIN STRING will acts like a wildcard for sub-domain
DOMAIN = '.phople.us'
CSRF_COOKIE_DOMAIN = DOMAIN
SESSION_COOKIE_DOMAIN = DOMAIN
SESSION_COOKIE_AGE = 1209600 # 2 weeks
"""
Following value should be same in all your django applications
CSRF_COOKIE_DOMAIN
CSRF_COOKIE_NAME
SESSION_COOKIE_DOMAIN
SESSION_COOKIE_NAME
SECRET_KEY
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment