0

I have 5 django website on my server. The problem is that I can't be logged-in in every website at the same time, when I login in website A and I click on another site B : I lose connection on A. I can only be logged with 1 site at a time.

4 sites works with sqlite and one with postgresql, every site has it's own folder. I use django 1.4 and DB session storage and mod wsgi.

Do you know how I can make user connection persistent so that I can be logged on all websites at the same time ? I don't know how to solve that issue, maybe it's a problem with the database, or my wsgi is not well configured.

Thanks.

Alex
  • 487
  • 1
  • 6
  • 16
  • Have you set a different `SESSION_COOKIE_DOMAIN` for each website? If it's the same are you using a different `SESSION_COOKIE_NAME`? – Ion Scerbatiuc Jun 10 '14 at 16:56
  • I don't use SESSION_COOKIE_DOMAIN, should I use that to resolve my issue ? – Alex Jun 10 '14 at 17:02
  • Well that depends on whether you site is using different domain or subdomains. What is your configuration for domain names? – Ion Scerbatiuc Jun 10 '14 at 17:10
  • I access my websites like this : www.site.fr/siteA www.site.fr/siteb, etc ... I can't access like this : sitea.site.fr – Alex Jun 10 '14 at 17:17
  • Ok. That's the problem. You are using the same domain for all the websites. You should set you `SESSION_COOKIE_PATH` to match each top-level path of the websites. More info [here](https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-path) – Ion Scerbatiuc Jun 10 '14 at 17:30
  • Ok i'll use cookie path – Alex Jun 10 '14 at 17:32

2 Answers2

0

Because you are using the same domain for all the websites you must set the SESSION_COOKIE_PATH in each Django website to point to the top-level path that the website is served from. You can find more details here

It's also advisable to set a different SESSION_COOKIE_NAME for each website.

Ion Scerbatiuc
  • 1,151
  • 6
  • 10
  • Ok, but when I set SESSION_COOKIE_PATH, the login does not work anymore, should I set this ? : django.contrib.sessions.backends.signed_cookies – Alex Jun 10 '14 at 17:42
  • How is you session configuration looking like for a website? Can I take a look? – Ion Scerbatiuc Jun 10 '14 at 21:03
  • Hi, what do you want to see ? settings.py ? – Alex Jun 11 '14 at 08:34
  • @Alex I'm glad you managed to fix the issue. Regarding the issue with the login, I think you had to remove the old cookie (the one with the default / path) from your browser in order to make it work. Also a few hints on how to share settings files: always remove all the sensitive data like SECRET_KEY, DATABASE credentials (if not sqlite) and any other credentials (like RECAPTCHA or AWS keys). I really encourage you to update you existing keys, especially if you are using this site in production. Sorry I forgot to mention this before. – Ion Scerbatiuc Jun 11 '14 at 15:42
0

finally I just changed SESSION_COOKIE_NAME and it works. Thanks for all.

Alex
  • 487
  • 1
  • 6
  • 16