I have this script to rotate redirects to offers. The problem is that i want it so if the person comes back that they are redirected to the same offer. i don't know how to code cookies though. what would i add here?
<?
//Tracking202 Offer Rotation Script
//enter your affiliate urls below, you can enter as many as you want, please
//make sure that you have the affiliate url with the SUBID syntax at the end
//of it, for reference goto: subids.com for more information.
$offer[1] = 'AFF LINK 1';
$offer[2] = 'AFF LINK 2';
$offer[3] = 'AFF LINK 3';
//this is the text file, which will be stored in the same directory as this file,
//count.txt needs to be CHMOD to 777, full privlledges, to read and write to it.
$myFile = "count.txt";
//open the txt file
$fh = @fopen($myFile, 'r');
$offerNumber = @fread($fh, 5);
@fclose($fh);
//see which landing page is next in line to be shown.
if ($offerNumber >= count($offer)) {
$offerNumber = 1;
} else {
$offerNumber = $offerNumber + 1;
}
//write to the txt file.
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $offerNumber . "\n";
fwrite($fh, $stringData);
fclose($fh);
//redirect to the affilate url, + add the subid at the end
header('location: ' .$offer[$offerNumber]);
?>
<?
//Tracking202 Offer Rotation Script
//enter your affiliate urls below, you can enter as many as you want, please
//make sure that you have the affiliate url with the SUBID syntax at the end
//of it, for reference goto: subids.com for more information.
$offer[1] = 'AFF LINK 1';
$offer[2] = 'AFF LINK 2';
$offer[3] = 'AFF LINK 3';
//this is the text file, which will be stored in the same directory as this file,
//count.txt needs to be CHMOD to 777, full privlledges, to read and write to it.
$myFile = "count.txt";
//open the txt file
$fh = @fopen($myFile, 'r');
$offerNumber = @fread($fh, 5);
@fclose($fh);
//see which landing page is next in line to be shown.
if ($offerNumber >= count($offer)) {
$offerNumber = 1;
} else {
$offerNumber = $offerNumber + 1;
}
//write to the txt file.
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $offerNumber . "\n";
fwrite($fh, $stringData);
fclose($fh);
//redirect to the affilate url, + add the subid at the end
header('location: ' .$offer[$offerNumber]);
?>