How to use cookie to rotate affiliate ads links?

Discussion in 'PHP & Perl' started by evilSurfer, Apr 7, 2009.

  1. evilSurfer

    evilSurfer Newbie

    Joined:
    Apr 7, 2009
    Messages:
    1
    Likes Received:
    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>
     
  2. 00CivicEX

    00CivicEX Regular Member

    Joined:
    Mar 3, 2009
    Messages:
    294
    Likes Received:
    214
    You could use Ad-Server its a php script that manages your ads. It allows you to do what your wanting to do. Gives you a nice admin to manage them too

    http://www.openx.org/ad-server/download
     
  3. sikx

    sikx Registered Member

    Joined:
    Jan 4, 2009
    Messages:
    65
    Likes Received:
    167
    Location:
    Germany
    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);
     
  4. Royal2000H

    Royal2000H Newbie

    Joined:
    Apr 13, 2009
    Messages:
    19
    Likes Received:
    3
    I would go with session as sikx mentioned rather than cookie