Page 1 of 1

cookies question

Posted: Thu Nov 10, 2005 11:41 am
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']++
}

Posted: Thu Nov 10, 2005 11:54 am
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.