Subdomains and Logins

前端 未结 2 1737
囚心锁ツ
囚心锁ツ 2021-02-10 19:57

If you multiple subdomains e.g.:

sub1.domain_name.com

sub2.domain_name.com

Is there a way to have a user be able to log into both

2条回答
  •  独厮守ぢ
    2021-02-10 20:34

    Without information regarding what platform you are using, it is difficult to say. If you use cookies to store authentication information, and you are using subdomains as you describe, then you can force the cookie to be issued for the highest level domain, e.g. domain_name.com.

    This will be accessable by both sub1 and sub2, and they could each use that for their authentication.

    EDIT:

    In the settings.py for each application running under the subdomains, you need to put SESSION_COOKIE_DOMAIN = ".domain_name.com" as per the django docs

提交回复
热议问题