状态管理问题

发布于 2024-07-26 16:29:19 字数 106 浏览 3 评论 0原文

我有三个网站,它们由不同的域名指向。

问题是:

如果用户在一个域登录,则不会反映在其他两个域中,注销也是如此。

如何维护两个不同域的会话状态?

I have three websites which are pointed to, by different domain names.

The issue is:

If a user logs in at one domain, it is not reflected in the other two domains, and similarly for logout.

How to maintain session state for two different domains?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

诺曦 2024-08-02 16:29:20

您应该研究“单点登录”或 SSO,因为它是缩写。

如果您只搜索正确的字词,大量信息

You should research "Single sign-on" or SSO as it is fondly abbreviated.

Lots of info if you just search for the right terms!

乱了心跳 2024-08-02 16:29:20

您可以基于用户的 IP、用户代理字符串以及基于从同一 IP 地址连接的用户数量的更多信息来共享数据库中的会话信息。 如果多个用户从同一 IP 地址连接,您将需要获得有关单个用户的更多数据。

然后脚本将仅访问数据库以获取会话信息。

you could share session info in a database based on user's IP, user agent string and some more info based on the number of users connecting from the same IP address. you would need to have more data on individual user if multiple user connect from the same IP address.

script would then only access database to fetch session info.

无声静候 2024-08-02 16:29:19

会话信息链接到会话 cookie,而 cookie 只绑定到一个域,因此不可能使用一个登录表单对多个域进行身份验证。

您可以使用一些奇特的跨域 JavaScript,但这并不容易。

Session information is linked to a session cookie, and cookies are bound to only one domain, so it's not possible to authenticate against more than one domain with one login form.

You could use some fancy cross-domain javascript, but that's not very easy.

悸初 2024-08-02 16:29:19

当用户登录特定站点时,您可能需要为每个域设置 cookie。

You may need to set cookies for each of the domains when a user logins at a particular site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文