tracking outgoing links

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jaymoore_299
Forum Contributor
Posts: 128
Joined: Wed May 11, 2005 6:40 pm
Contact:

tracking outgoing links

Post by jaymoore_299 »

Let's say I have a random link generator with 10 links. How do I make it so that the surfer is randomly given a link from the 10 links at each request, so that the surfer is never given a link he has already been to? (through use of cookies)

I thought about giving each surfer a unique array of links, and at each request a random url would be selected, then taken out of that array. But then I didn't know how to incorporate this with cookies. (i'd probably have to use the mysql database, which would make it slower for the surfer)

Now I was thinking about giving the new surfer a number, like 0000000000
with each 0 representing a position in an array of links. At each request
a random position would be selected, then the corresponding array would be something like 0100000000 (1 for the location in spot #2 of the array of links that has already been visited.)

Anyone have a better idea?
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

Post by method_man »

i think i remember this coming up another time on the forums
did you try searching the forums?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Way to difficult ;) Simply store the ids of links that have been clicked by the user in the cookie...


This way, when you retrieve the next link all you need to generate is a WHERE clause. For example, assume urls with id 10 and 15 have been shown already -> SELECT * FROM links WHERE id NOT IN (10, 15)
Post Reply