In Django, I have SESSION_COOKIE_DOMAIN set to my domain name. But I would actually like to run the same site with two different domain names.
With SESSION_COOKIE_DOMAIN set, only the named domain allows the user to login. Is it possible to allow both domains to login?
If you set your session cookie domain to start with a "." character it will let you handle wildcard sub-domains and share a session cookie (login session) across multiple subdomains.
The above would allow a cookie to be shared across user1.stackoverflow.com and user2.stackoverflow.com.
If you really do want the url's to be different for the same site, would you want the same user to switch between the two sites on one login session? Or do you just want the ability to have two different users login to the site from two different url's (that are not sub-domains?)
Instead of having a complete new SessionMiddleware you could alter the response cookies as following:
(Place this Middleware above your Session Middleware) You can restrict this to specific domains if you like.
The standard SessionMiddleware only supports one SESSION_COOKIE_DOMAIN, which is only good for one domain and subdomains thereof.
Here's a variation that will set the cookie domain dynamically based on the request host. To use it, just update your MIDDLEWARE_CLASSES to use this one SessionHostDomainMiddleware, instead of SessionMiddleware. This better, @jcdyer and @interstar?
I think this is what you are looking for, I took me hours to find it out
https://bitbucket.org/uysrc/django-dynamicsites