I know this is a bit stupid and there's probably a smarter way. But are there a way to generate a session variable just by visiting a specific website. What I want to do is that I want a customer to visit one website before visiting another website. And also, is there a way so a session variable can only be used once? thanks! :)
Just to clear everything. What I didn't know existed was the unset function. I wanted the user of the website to visit the first page first, then the next and then the final page. I also wanted it in a way that if the user wants to visit the second page he/she would first have to visit the first again. It's super simple and I don't know why I didn't know this. Here's what I did:
First page:
<?php
session_start();
$_SESSION['second_page']=true;
?>
Second page:
<?php
session_start();
if ($_SESSION['second_page']==true){}
else {
header('Location: example.php');
exit;
}
unset($_SESSION["second_page"]);
$_SESSION['final_page']=true;
?>
Final page:
<?php
session_start();
if ($_SESSION['final_page']==true){}
else {
header('Location: example.php');
exit;
}
?>