【问题标题】:PHP Sessions on multiple sites多个站点上的 PHP 会话
【发布时间】:2013-07-29 16:03:04
【问题描述】:

我在服务器上托管了多个站点,其中大多数站点在用户登录时使用会话。

例如,如果用户登录成功,我有一个会话变量$_SESSION["loggedin"] = 'yes'

这在多个站点上是相同的,但如果我同时登录说 2 个站点,其中一个站点将停止工作并显示这些错误:

Warning: session_start() [function.session-start]: open(/tmp/sess_8f7b4997fbfdd08855a410ae4638821f, O_RDWR) failed: Permission denied (13) in /home/theboaty/public_html/new_site/admin/authorisation.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/theboaty/public_html/new_site/admin/authorisation.php:2) in /home/theboaty/public_html/new_site/admin/authorisation.php on line 2

Warning: Cannot modify header information - headers already sent by (output started at /home/theboaty/public_html/new_site/admin/authorisation.php:2) in /home/theboaty/public_html/new_site/admin/authorisation.php on line 5

Warning: Unknown: open(/tmp/sess_8f7b4997fbfdd08855a410ae4638821f, O_RDWR) failed: Permission denied (13) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0

注意:authorisation.php 检查 loggedin 会话变量以查看用户是否已登录

【问题讨论】:

  • 您是否在站点之间共享(或有意或无意地)相同的会话 ID?
  • 添加新站点时,代码只是被复制。不是故意的
  • 如果您使用的是Firefox,可以通过右键单击页面并选择“查看页面信息->安全->Cookies”来访问cookie管理器。
  • 您的会话正在设置 cookie。
  • 通过 cookie 管理器,您可以看到哪些会话 id 是活动的。看起来“authorisation.php”试图对所有站点使用相同的会话。

标签: php session


【解决方案1】:

我有很多相同的问题,因为我使用了一个接受会话的自定义用户处理程序。

我发现使用相同的浏览器窗口登录同一服务器上的两个不同的相关站点,但使用不同的选项卡存在串扰。

如果这不可接受,我建议您通过站点 vis 重命名会话变量:

$_SESSION['site1']['isloggedin']=1;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-19
    • 1970-01-01
    • 1970-01-01
    • 2010-10-25
    • 1970-01-01
    相关资源
    最近更新 更多