page1.php中
$for = $_GET['name'];
session_start();
$_SESSION['new'] = $for;
session_write_close();
header('Location: http://newwebsite.com);
使page2.php
<?php
$new = '';
session_start();
$new = $_SESSION['new'];
?>
<script>
$(document).ready(function()
{
<?php if($new != '') { ?>
var banner = document.getElementById("A");
var hiddenInput = document.getElementById("B");
banner.innerHTML = <?php echo "'".$new."'" ?>;
hiddenInput.value = <?php echo "'".$new."'" ?>;
<?php }
if(session_destroy())
{
unset($_SESSION['new']);
}
?>
});
</script>
我从page1.php获取数据但是它似乎永远不会被清除。
如果我这样做
print_r($_SESSION);
导致空输出,但下次我从page1.php到另一个变量的页面时,它仍然显示旧的变量。我该怎么办?