Image

Imageduckspeaker wrote in Imagephp

Random Numbers and Cookies

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<br>");
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?