使用PHP传递会话变量的问题[重复]

I'm trying to understand session variables by trying this code. For the purpose of the test, I created 3 pages and tried to pass the session variables around. I noticed that, the session variable is not populated in the 3rd page. I have searched to see where the problem is and I'm yet to figure it out.

page1

<!DOCTYPE html>
<html lang="en">    
    <head>
        <meta charset="UTF-8">
        <title>Bio Data</title>
    </head> 
    <body>
        <form action="process.php" method="post">
            <label for="fst_name">
                First Name
                <input type="text" name="fst_name" id="fst_name">
            </label>

            <label for="lst_name">
                Last Name
                <input type="text" name="lst_name" id="lst_name">
            </label>

            <input name="submit" type="submit" value=" Login ">
        </form>
    </body>
</html>

page2

<?php
session_start();

if (isset($_POST["submit"])){           
    $_SESSION['fst_name'] = $_POST['fst_name'] ;
    $_SESSION['lst_name' ] = $_POST['lst_name'] ;
    header("location:display.php");
}else{
    echo "Error";
}

page3

<?php
session_start();
echo $_SESSION['fst_name'];
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Biodata Display</title>
    </head>
    <body>
        <table>
            <tr>
                <td><?php echo "Hello " .  $_SESSION['fst_name']; ?></td>
                <td><?php echo $_SESSION['lst_name']; ?></td>
            </tr>
        </table>    
    </body>
</html>
</div>

Sessions in PHP work by saving a data file server side referenced by a special cookie (by default named PHPSESSID), so when your browser sends the proper cookie PHP fetches from the saved data files the previous $_SESSION value. This means that:

  1. Your server must be able to write files (usually in tmp dir, check PHP INI settings related to session save path
  2. Your browser must accept cookies (you can easily check this by dumping $_COOKIE)

To simplify your test, create a single page like this:

<?php
session_start();
header("Content-Type: text/plain");
var_dump($_COOKIE);
var_dump($_SESSION);
$_SESSION['hello'] = "world";

After you load this page TWICE, you should see the right data in $_SESSION and $_COOKIE. If it doesn't work, your problem is in your server/environment. If that works, I'll look again at your code but it looked fine on first sight.