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>
I get my data from page1.php but when it never seems to get cleared.
If I do
print_r($_SESSION);
It results in empty output, but next time I come to the page with a different variable from page1.php it still shows me the older variable. What can I do?