Can this work? Execute PHP once based on Variable + header redirect?

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.




Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories