[Answer]-Best way to redirect to another domain in django and be logged on new domain

1👍

You’re asking for Single Sign On (SSO). It’s a rather rich and complex topic. There are some available django solutions like django-sso.

Here’s another stack overflow question on SSO with django:
Implementing Single Sign On (SSO) using Django

0👍

If these domains are subdomains of the same 2nd level domain then you can use the SESSION_COOKIE_DOMAIN setting:

SESSION_COOKIE_DOMAIN = '*.somedomain.com'

If domains are totally different then you in trouble. You can’t set cookie for the external domain.

I think you have to create a special view on the second domain which will receive the session_key in the GET parameter and set the cookie for the second domain.

To prevent attacks you can store in the session some info about the user (at least the IP and User-Agent) at the first domain and compare this data against the visitor of the the second site.

Leave a comment