Why in the world does this not work:
if(isset($_COOKIE['creature_hp'])) {
}
else {
$cookie_life = time() + 31536000;
setcookie('creature_hp', $monster_hp, $cookie_life);
echo $monster_hp;
echo "got here";
echo $_COOKIE['creature_hp'];
}
$creature_hp = $_COOKIE['creature_hp'];
Here's what I get:
10got here
Notice: Undefined index: creature_hp in C:\Program Files\Apache Group\Apache2\htdocs\vod\gamev2\fight.php on line 54
Notice: Undefined index: creature_hp in C:\Program Files\Apache Group\Apache2\htdocs\vod\gamev2\fight.php on line 57
Which means to me that $monster_hp = 10 which means that the code SHOULD be getting to that point and therefore setting the cookie but then the next line defies all that by saying nothing is defined.
Help? Please?
P.S. > If I refresh the page after clicking the link to get there, it seems to sorta work. No clue why.