PDA

View Full Version : Redirect Recent Visitors Within Day?


oooyeaherz
08-06-2005, 09:58 PM
After gnawing over this problem for a good while I figure that this problem is best handled thru server side. Whether client or server side I'm still at a loss here in this problem. :(

You see I have two possible affiliate links that I want to redirect people to. So i'll have the redirect code on a page on my domain called theurl.htm to take an individual to... lets say gamespot.com
HOWEVER
If this same person (or at least this same computer) passes by theurl.htm from within the same day (or 24 hour span), then I would like this person to go to www.cnet.com .

Since what I want is requiring a specific individual (ip address) within a specific time slot to be redirected whether or not they have been passing by within the past 24 hours, my guess would be a server side procedure since client side would probably involve something like cookies which may be too much of a hassle to deal with while capturing their ip address & recording it on server is perhaps more fiesable.

Anybody help me out on this? Somebody? I'll continue to search for a solution so i won't be too much of a lazy ******* but any help on this would be greatly appreciated since I've found nothing as of yet through countless google searches and disasterous coding of my own :\

Kurashu
08-06-2005, 10:12 PM
Store the IP and a timestamp (Unix perferably) in a database of somesort and then compare differences in time.


//I'll assume that you have connected to the database already and pulled out the information

$day = 60 * 60 * 24;
$diff = time('u') - $row['time'];

if($diff > $day) {
//store data so that this person doesn't get redirect to gamespot again until 24 hours is up
header('Location: http://www.gamespot.com');
}

else {
//don't store data because this person has been here once before in the last 24 hours
header('Location: cnet.com');
}