Heres the code I used:
if (!empty($_COOKIE['testcookie'])) {
setcookie("testcookie", "The cookie has value!!!", time() + 60*60*24*1, '/', 'watup.servehttp.com:8080');
header("Location: $PHP_SELF?okay"); /* Query string doesn't do anything ... it's just to refresh the page. */
} else {
$thecookie = $_COOKIE['testcookie'];
echo $thecookie;
}
but the result is nothing.
Look here: http://watup.servehttp.com:8080/cookietester.php
I haven't worked with cookies before tho, so if I'm wrong, can you give me an example to use?
EDIT: I changed it to use an eample from php.net. It's on the same page, but the code is:
<?php
// set the cookies
setcookie ("cookie[three]", "cookiethree");
setcookie ("cookie[two]", "cookietwo");
setcookie ("cookie[one]", "cookieone");
// after the page reloads, print them out
if (isset($_COOKIE['cookie'])) {
foreach ($_COOKIE['cookie'] as $name => $value) {
echo "$name : $value <br />\n";
}
}
/* which prints
three : cookiethree
two : cookietwo
one : cookieone
*/
?>
This worked for me.