Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
05-18-2012, 10:08 PM #1
- Join Date
- Mar 2012
- Thanked 5 Times in 4 Posts
How do i make a different ad come up when someone refreshes the page?
You know how google has different ads everytime you go to a page? Well i want to do the same thing. I got two banners and i want one to change to the other banner when someone refreshes the page.
05-19-2012, 12:42 AM #2
So just check for the cookie and, if it is not there, pick an ad at random. Then "remember" the ads the user has seen in the cookie. If the cookie is there, then just pick a random ad the user hasn't already seen.Be yourself. No one else is as qualified.
05-19-2012, 02:53 AM #3On the next page load, start from step 2.
If you are concerned about users who don't have cookies enabled, then instead of pulling the ads sequentially from the array, you would pull them randomly. And in the cookie you would keep a list of *all* the ads that have so far been displayed, so that you could remove them from the array before picking one at random. When the array is empty, you just start all over: clear out the list and pick any of them at random.Be yourself. No one else is as qualified.
05-19-2012, 08:39 AM #4
- Join Date
- Jun 2002
- London, England
- Thanked 2,672 Times in 2,648 Posts
Last edited by Philip M; 05-19-2012 at 08:42 AM.
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.