[thelist] Some PHP & Image questions

Kristian Duske ml.duske at gmx.net
Fri Mar 8 03:50:00 CST 2002


Burhan,

> $cookie  = $HTTP_COOKIE_VARS["RandomVal"];
> if (!$cookie) {
> setcookie("RandomVal",$randomNumber,time() + 3600);
> }

First off, I agree with Andrew on dropping the cookies altogether, but
anyway... I think your problem might be the if (!$cookie) test - I haven't
tested it, but it's definitely a better method to do this:

if (!isset($HTTP_COOKIE_VARS["RandomVal"])) {
	setcookie()
} else {
	$cookie = $HTTP_COOKIE_VARS["RandomVal"];
...
} //if

Also when I was working with cookies, I noticed that it's really a hassle to
use them in PHP. It took me quite some time to figure out how to correctly
set a cookie, so you're not alone =). Anyway, you might want to try to
increase your cookie's lifetime during your tests to avoid running into
errors due to the server time being off - I experienced that, too.

Good luck
Kristian




More information about the thelist mailing list