具有多个域的Django,SESSION_COOKIE_DOMAIN [英] Django, SESSION_COOKIE_DOMAIN with multiple domains

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

问题描述

在Django中,我将SESSION_COOKIE_DOMAIN设置为我的域名。但是我实际上希望使用两个不同的域名运行相同的站点。

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.

设置SESSION_COOKIE_DOMAIN,只有命名域允许用户登录。是否可以允许两个域登录?

With SESSION_COOKIE_DOMAIN set, only the named domain allows the user to login. Is it possible to allow both domains to login?

推荐答案

如果您将会话cookie域设置为以。开头。字符,它将让您处理通配符子域并在多个子域中共享会话cookie(登录会话)。

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"

以上将允许在user1.stackoverflow.com和user2.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?)

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

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