Page 1 of 1

tracking outgoing links

Posted: Mon Jun 20, 2005 11:21 pm
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?

Posted: Mon Jun 20, 2005 11:50 pm
by method_man
i think i remember this coming up another time on the forums
did you try searching the forums?

Posted: Tue Jun 21, 2005 1:09 am
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)