Random Numbers and Cookies
Date: 10/05/06
(PHP Community) Keywords: no keywords
I set a random number
$randomc = rand(1, 10000);
I set a cookie
setcookie("tpf",$randomc);
I echo back out the number and the cookie
Echo ("random number c: $randomc
");
echo $_COOKIE["tpf"];
What I get
The random number and cookie are different.
If I refresh the screen, I get a new random number (as expected) but the cookie becomes the last random number set.
I’ve looked at documentation for rand and mt_rand----I’m scratching my head.
I'm sure it's something basic...
Suggestions?
Source: http://community.livejournal.com/php/500424.html