子域名和登录名 [英] Subdomains and Logins

查看:154
本文介绍了子域名和登录名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您有多个子域,例如:

If you multiple subdomains e.g.:


sub1.domain_name.com

sub1.domain_name.com

sub2.domain_name.com

sub2.domain_name.com

有没有办法使用户能够登录这两个没有问题和双重登录问题?

Is there a way to have a user be able to log into both of these without issues and double login issue?

平台是Python,Django。

The platform is Python, Django.

推荐答案

关于你正在使用什么平台的信息,很难说。如果您使用Cookie来存储身份验证信息,并且您正在使用子域,则可以强制为最高级别域颁发Cookie。 domain_name.com。

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.

这可以由sub1和sub2访问,他们可以使用它们进行身份验证。

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

编辑:

在子域下运行的每个应用程序的settings.py中,您需要将
SESSION_COOKIE_DOMAIN =.domain_name.com根据 django文档

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

这篇关于子域名和登录名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆