Click to See Complete Forum and Search --> : $_COOKIE["submit*2"]
gert cuykens
02-18-2006, 05:24 AM
i got the cookie working except i have to push 2 times the submit button to read the cookie :mad:
i tryed this but doesnt work
setcookie("TestCookie", $value, time()+3600);
ob_start();
ob_get_contents();
print_r($_COOKIE);
ob_end_clean();
bathurst_guy
02-18-2006, 05:31 AM
Is the submit button, the cookie set and the print_r on the same page?
gert cuykens
02-18-2006, 05:38 AM
yes i want to transform a cookie into a sql database :D
is there no way to set a cookie and read the cookie on the same page with some flush magic or something ?
bathurst_guy
02-18-2006, 05:45 AM
php.net manual (http://php.planetmirror.com/manual/en/function.setcookie.php) Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires. Expire time is set via the expire parameter. A nice way to debug the existence of cookies is by simply calling print_r($_COOKIE);.
gert cuykens
02-18-2006, 05:48 AM
i know but is there no way around it :D
maybe with some header location right after the setcookie , wait a minute i have a idea, back to the drawing board :)
bathurst_guy
02-18-2006, 05:53 AM
Well why not jump to another page, complete the sql query and then jump back again?
gert cuykens
02-18-2006, 06:20 AM
if ($_GET['cookie'] != 'yes') {
setcookie("data",$data, time() + 3600);
header ("Location: index.php?cookie=yes");
}
it works :D
bathurst_guy
02-18-2006, 06:21 AM
Fair enough lol