多个站点上的PHP会话


PHP Sessions on multiple sites

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

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

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

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会话变量以查看用户是否已登录

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

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

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

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