views:

347

answers:

2

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?

A: 

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.

In settings.py:
SESSION_COOKIE_DOMAIN=".stackoverflow.com"

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?)

MikeN
I want the second. Not sub-domains. Basically I have a client who has averylongdomainnamethatno-onewantstotype.net and quickname.net and the site needs to work for both.
interstar
A: 

It's imposible, you cannot assign cookie for other domains.

Igor