How to use cookie to rotate affiliate ads links?

evilSurfer

Newbie
Joined
Apr 7, 2009
Messages
1
Reaction score
0
I'm pretty new to this online marketing thing, I picked 10 clickbank products, find a rotator script on this forum, and put it up on a pay to surf website.

My question is: how can I modify the script so it show the same user different product each time he click on my index page. I believe I need to use cookie, but not sure exactly how.

Thank you very much for your help

======
<head>
<?php

$offers = array(
"mysite page1",
"mysite page2",
"mysite page3",
"mysite page4",
"mysite page5"
);

$referer = $_SERVER['HTTP_REFERER'];
if($referer == "") {
$url = $offers[rand(0, count($offers) - 1)];
echo "<meta http-equiv='refresh' content='0;url=$url'>";
}
else
{
echo "<meta http-equiv='refresh' content='0;url=mysite'>";
}
?>
</head>
 
You can either use a cookie and store the current index of the array of your offers in it, or more simply you can use Sessions (session_start() etc, look it up on php.net), and store the index there. You can simply iterate through them and start from the beginning again then: $_SESSION['offer'] = ($_SESSION['offer'] + 1) % count($offers);
 
Back
Top