简体   繁体   English

本地网络下的 Kohana PHP 会话问题

[英]Kohana PHP sessions problem under a local network

I have a kohana (php) web site and we have a problem with the sessions when used by computers on a local network under a proxy.我有一个 kohana (php) web 站点,当本地网络上的计算机在代理下使用会话时,我们遇到了问题。

The problem: PC 1 and PC 2 are in the same local network.问题:PC 1 和 PC 2 在同一个本地网络中。 They use a proxy server to access the external web site.他们使用代理服务器访问外部 web 站点。 PC 1 access the site with "USER A", he is in the main page now and the site says "Connected with USER A". PC 1 使用“用户 A”访问该站点,他现在在主页上,该站点显示“与用户 A 连接”。 PC 2 enters the site and access with "USER B", he is in the main page now and the site says "Connected with USER B". PC 2 进入站点并使用“USER B”访问,他现在在主页上并且站点显示“与 USER B 连接”。 PC 1 press F5 to reload the site main page, and the site now says that is logged with "USER B". PC 1 按 F5 重新加载站点主页,该站点现在显示已使用“USER B”记录。

The system is installed externally and we have this problem only in this under-proxy network.系统是在外部安装的,我们只在这个代理网络中遇到这个问题。 Access from other PCs also under local networks (but no proxy) don have this problem.从本地网络(但没有代理)下的其他 PC 访问没有这个问题。

We enabled the "user_token" part in the auth module (it uses a new table named "user_tokens" that uses the browser user agent), but the problem persists.我们在 auth 模块中启用了“user_token”部分(它使用了一个名为“user_tokens”的新表,该表使用了浏览器用户代理),但问题仍然存在。

-- edit -- We are using Kohana 3.0, PHP 5.2.9 and postgres 8.4 -- 编辑 -- 我们使用的是 Kohana 3.0、PHP 5.2.9 和 postgres 8.4

Does your proxy support caching?您的代理是否支持缓存? It should NOT cache pages which are different if the client is logged in.如果客户端登录,它应该缓存不同的页面。

You application may have to set appropriate HTTP headers to tell the proxy that it is not allowed to cache HTTP responses.您的应用程序可能必须设置适当的 HTTP 标头来告诉代理它不允许缓存 HTTP 响应。

If this doesn't fix it, make sure you're not using the client IP address as the Session key.如果这不能解决问题,请确保您没有使用客户端 IP 地址作为 Session 密钥。 (If you still fancy using the IP, create a whitelist for allowed proxies, then use the HTTP forwarded_for header. It'll only fix the problem for proxies you trust though.) (如果您仍然喜欢使用 IP,请为允许的代理创建白名单,然后使用 HTTP forwarded_for header。它只会解决您的问题。)

Can you turn the proxy off temporarily to confirm the issue?您可以暂时关闭代理以确认问题吗?

Can you try accessing the site with Firefox and the Firebug extension?您可以尝试使用 Firefox 和 Firebug 扩展访问该站点吗? This will let you see the exact HTTP response codes and headers that are being sent from the site.这将使您看到从站点发送的确切 HTTP 响应代码和标头。 Knowing what they are will help us diagnose the problem for you.了解它们将帮助我们为您诊断问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM