从一个目录深度设置时,不会保留会话变量

时间:2016-07-28 15:30:10

标签: php session

这是一个奇怪的问题。我有这样的文件夹结构。我简化了这个问题。

文件夹结构

enter image description here

会话变量id由文件夹index.php内名为deep的文件设置然后,当我回到根文件夹并打开index.php会话时变量不会显示出来。 (它的值没有设置)

文件中的代码:deep / index.php:

<?php
    session_start();
    echo session_id();
    $_SESSION['id'] = "bro";
    print_r($_SESSION);
?>

文件中的代码:/index.php:

<?php
    session_start();
    echo session_id();

    print_r($_SESSION);
?>

此示例适用于我的localhost。 (/index文件显示一个带有Session变量的数组。)但是在我的实时服务器上它不起作用。 /index显示Array(),同时显示设置数据。虽然, session_id()匹配。它实际上是一个子域名(something.somewhere.com),并不是真正以&#34; www&#34;开头。

0 个答案:

没有答案
相关问题