Ask Your Question

cookie domain-subdomain

asked 2011-07-14 03:36:39 -0500

DominiCattus gravatar image

updated 2011-07-20 07:29:33 -0500

Hi all!
I've deployed askbot on subdomain and I have another django application (blogs) that runs on main domain. Both share the same database, so users are registered and logged in only with askbot.
But now I want users that logged in on subdomain will be "logged in" on main domain automatically, and vice versa of course.
I added SESSION_COOKIE_DOMAIN = '' to both askbot and blogs, but it doesn't help. What is common solution for this?
P.S. Tow applications are different django instances that everyone in its own virtualenv with own '' file. Thanks!

Configs are same for two sites:

'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '',
        'KEY_PREFIX': 'production'

#SESSION_ENGINE = 'django.contrib.sessions.backends.cache'

I've tried various session engines, but seems that problem is not here..

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-07-14 03:38:16 -0500

Evgeny gravatar image

updated 2011-07-14 03:42:17 -0500


(With the leading "dot" before "mydomain")

Does that help?

edit flag offensive delete link more


No, doesn't help unfortunately. I see that both sites have cookie "", share the same session_id, just askbot site have also askbot_csrf cookie, and csrf_token that points to "" without dot. When I log in to one site, the other doesn't detect it.. When I log in with this user on other site also, he is logged out on the first one. Strange...
DominiCattus gravatar imageDominiCattus ( 2011-07-15 01:40:42 -0500 )edit
The leading dot makes the cookies recognizable across subdomains, so for any cookies you want to work like that - add the dot. Does common login work? If not probably it is because you are not sharing the session data between the sites.
Evgeny gravatar imageEvgeny ( 2011-07-15 08:39:47 -0500 )edit
You're right. Looks like sessions conflict each with other. Any clue what can cause it? django_session is uniq table in DB that two sites use. Maybe caching sessions settings break the things here..
DominiCattus gravatar imageDominiCattus ( 2011-07-20 07:31:27 -0500 )edit
I think the two sites are using different sessions, even though you save them all in the same table, I am reading the docs now. But why don't you install both on the same django project - is that impossible?
Evgeny gravatar imageEvgeny ( 2011-07-20 13:04:08 -0500 )edit
Yeah.. Seems that it will be the final solution for this )) If using askbot as app, that's OK.
DominiCattus gravatar imageDominiCattus ( 2011-07-20 19:45:37 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-07-14 03:36:39 -0500

Seen: 1,440 times

Last updated: Jul 20 '11