cookies question

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:

cookies question

Post by jaymoore_299 »

I have never used cookies before.

If I have 100 surfers coming from a certain domain, how do I give them all their own cookies so that for every 7th click for each surfer they are redirected to some random site?

is it as easy as this? Include this code in main page

Code: Select all

setcookie ("links", "0");
for each link I make them like this
http://www.domain.com/out.php?url=http: ... dress.html
and inside each out.php

Code: Select all

if ($_COOKIE['links']==7)
{
// redirect code goes here
$_COOKIE['links']++
}
else
{
// go to value inside url variable
$_COOKIE['links']++
}
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

Yea, it is that easy. Why not try it out? It's probably faster than waiting for an answer! :wink:

Check out the entry on Cookies in the PHP Manual.
Post Reply