如何避免应用程序的不同实例之间不必要的会话遗留

发布于 2025-01-01 05:44:08 字数 247 浏览 2 评论 0原文

场景

我在一个 Chrome 选项卡(开发环境)中打开了 Zend Framework 应用程序的本地版本。同时,我还打开了在远程服务器上运行的同一应用程序的舞台或实时版本。我已登录其中一个实例。当我尝试登录另一个实例时,该实例会退出并出现致命错误,直到我删除了我首先登录的另一个实例的 cookie。

会话 cookie 上的域设置不相同,但结转仍然发生。

问题

为什么会发生这种情况?
我怎样才能避免它?

Scenario

I have the local version of a Zend Framework application open in one Chrome tab (development environment). At the same time I have the stage or live version of the same application running on a remote server open as well. I'm logged in one of the instances. When I try to log in to the other, this instance exits with a fatal error until I delete the cookies of the other instance, where I'm logged in first.

The domain setting on the session cookies is not identical but the carry-over still happens.

Questions

Why does that happen?
How can I avoid it?

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

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

发布评论

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

评论(2

海未深 2025-01-08 05:44:08

为每个服务器指定不同的会话名称(不是默认名称),以便您拥有不同的会话。如果您想使用彼此相邻的多个会话,这通常会起作用(并且您不想检查 cookie 设置,例如注意 cookie 仅在其域中工作,并且在 cookie 旁边没有其他任何内容用于传递 ID) 。

在本机 PHP 中,它是 session_name,我假设 Zend Framework 也有相应的配置设置。

Give each server a different session name (not the default one), so that you have different sessions. This does normally work if you want to use multiple sessions next to each other (and you don't want to check the cookie settings like taking care cookie works in it's domain only and that next to cookie nothing else is used to pass the ID).

In native PHP it's session_name, I assume Zend Framework has a corresponding configuration setting as well.

他夏了夏天 2025-01-08 05:44:08

两者的会话 cookie 的域设置是什么?如果它是顶级的,例如 .example.com,那么该 cookie 将在两个系统之间共享。您可以将其固定为 local.example.comremote.example.com,这样会话 Cookie 是不同的并且不会重叠。

What is the domain setting on the session cookies for both? If it's a top level one, like .example.com, then the cookie'll be shared across both systems. You could nail it down to local.example.com and remote.example.com so the session cookies are distinct and won't overlap.

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