What I’m trying to do is a secret link for example website.com/?secret=yes when they visit this page i want to remove this variable from URL so I have the following:
<?php
if(isset($_GET['secret']) && $_GET['secret'] === 'yes') {
header('Location: http://website.com');
$secret="yes"; <--take note this is what I'm testing
}
?>
The above code will redirect instantly so there is no variable in url and I tryed to make this variable myself with $secret=”yes”; to be able to use it with the following code:
<?php if( 'yes' === $secret ) : ?>
secret content here
<?php endif; ?>
Is this possible? How can I make my code work? I do not want to use session because I want it to do this only once, or everytime they access via the secret link, if they access without it don’t show.
No, that won’t work. Variables do not persist through reloading pages. You can however use sessions or cookies to do this: