I'm trying to make a session script that will only allow people to load a page if they visted the page with this code on it:
<?php
// Start the session and pass the visitor the ticket
session_start();
$ticket = "admitone";
session_register($_SESSION["ticket"]);
?>
<a href="ticket1code.php?filename=555">TEST</a>
Ok, so someone loads that page and clicks the link. If they tried to visit that link with out first loading the page starting the session they would see a message saying they are illegally linking. Here's the ticket1code.php code:
<?php
// ticket1code.php
session_start();
// Check to see if the visitor has the right ticket
if ( $_SESSION["ticket"] == "admitone" ) {
echo "This script works: $filename ";
} else {
echo "you are illegally linking";
}
?>
Whenever I run this code, the "you are illegally linking" message always appears even though I visit the page starting the session which I posted at the top of this message.
I would really like to know what I'm doing wrong. I'm using PHP 4.1.1. Any help would be greatly appreciated.
RogeR