I use cookies (I've tried both PHP and Javascript) to "send" values between two pages. On the first page I do that:
setcookie("url", $url, time()+3600);
Then I'm doing a redirect with Javascript:
window.location.href =location.protocol+'//'+document.domain+'/example.php';
And then in example.php I do that:
<?php
echo $_COOKIE['url'];
$url = $_COOKIE['url'];
setcookie ("url", "", time() - 3600)
?>
<script
type="text/javascript" src=<?php echo $url?>>
</script>
The value of $url changes depending on some conditions before I set the cookie. The problem is that cookie has always the same value. What I'm doing wrong?