php会话变量到期

use*_*885 1 php session

我正在使用会话变量进行身份验证,据我所知,即使加载了新页面,会话变量也应该存储在服务器上.我使用以下代码:

    <?php
session_start();
echo $_POST['path'];

if($_POST['path']=="index")
{
    $_SESSION['rightPath']=1;
    if(isset($_SESSION['rightPath']))
        echo "it is set";
    ?>
    <script type="text/javascript">parent.location='UI.php'</script>
    <?php   
}
else
{?>
<script type="text/javascript">parent.location='index.php'</script>
<?php   
}
?>
Run Code Online (Sandbox Code Playgroud)

这里的isset函数告诉我变量已设置,但在下一页ui.php中它没有给我相同的结果.

    <?php
    if(!isset($_SESSION['rightPath']))
    {
        echo "it not is set";?>

<?php   }
?>
Run Code Online (Sandbox Code Playgroud)

这是ui.php页面代码段.这里if语句正在执行.

我究竟做错了什么 ?

sha*_*han 5

你需要在这里开始会议很好

<?php
        session_start();
        if(!isset($_SESSION['rightPath']))
        {
            echo "it not is set";?>

    <?php   }
    ?>
Run Code Online (Sandbox Code Playgroud)