会话无法清除

Look at the example code directly:

<?php
// page1.php

session_start();

echo 'Welcome to page #1';

$_SESSION['favcolor'] = 'green';
$_SESSION['animal']   = 'cat';
$_SESSION['time']     = time();
echo '<br /><a href="page2.php">page 2</a>';

?>

And another page:

<?php
// page2.php

session_destroy();
session_unset();
session_start();

echo 'Welcome to page #2<br />';

echo $_SESSION['favcolor']; // green
echo $_SESSION['animal'];   // cat
echo date('Y m d H:i:s', $_SESSION['time']);

echo '<br /><a href="page1.php">page 1</a>';
?>

Although I call session_destroy(), session_unset(), I still get the data coming from page1. why? and how to really clear the session? Thanks!

This should do the trick

session_start();
$_SESSION = array();
session_unset();

But just for clarity, this is happening to you because you have to call session_start() first

session_start();
session_destroy();
session_unset();

You have to start the session first on the second page page2.php.Put session_start(); at the top on second page.