会议采取和丢失

时间:2017-05-06 19:19:24

标签: php session

请帮助解决这个问题。 场景很复杂,但实质上是:

  1. first-file.php的内容

    <?php
    
    session_start();
    
    $_SESSION['s_Foo'] = "pippo";
    
    /* this is only a twisted way of producing the header('location: second-file.php'), because unfortunately often I obtain the error "headers already sent". */
    
    echo "<!DOCTYPE html><html>";
    
    echo "<head>&#60;meta charset='utf-8'>&#60;/head>";
    
    echo "<body onload='go()'>";
    
    echo "<script>function go(){location.replace(\"second-file.php\")}</script>";
    
    echo "</body>";
    
    echo "</html>";
    
    exit;
    
    ?>
    
  2. second-file.php的内容

    <?php
    
    session_start();
    
    $foo = isset($_SESSION['s_Foo']) ? $_SESSION['s_Foo'] : "nothing";
    
    echo $foo;
    
    ...
    here a line that require to use $_SESSION['s_Foo']
    
    ?>
    
  3. 现在,我读了(在secon文件中)“ pippo ”,但只有一半或一秒...... 然后消失“ pippo ”,并在php日志中写入“ nothing ”,注意:未定义的索引:[...] / second-file.php中的s_Foo第4行

    提前谢谢你, 弗朗西斯

0 个答案:

没有答案