Jump to content

Cookies not retrieving


smguy

Recommended Posts

Hey everyone. I'm a pretty new PHP coder and I've been working on a little pet project, a game while teaching myself PHP from online tutorials. I have xampp at home and I use the school web servers while I'm at the lab there and my code has worked perfectly until about two days ago, when it suddenly stopped retrieving my cookies.

<?php
$maxhp = $_COOKIE['maxhp'];
$hp = $_COOKIE['hp'];
$exp = $_COOKIE['exp'];
$race = $_COOKIE['race'];
$gold = $_COOKIE['gold'];
$str = $_COOKIE['str'];
$agi = $_COOKIE['agi'];
$vit = $_COOKIE['vit'];
$luk = $_COOKIE['luk'];
function head() {
echo '<head>
<title>Blah</title>
<style>
body{
background-color:#000000;
color:#FFFFFF;
font-family:"lucida console";
font-weight:bolder;
}
</style>
</head>
<body>';
echo $race."<br />HP: ".$hp."/".$maxhp."<br />Str: ".$str."<br />Agi: ".$agi."<br />Vit: ".$vit."<br />Luk: ".$luk."<br />".$gold." gp, ".$exp." exp.";
};
?>

That's the code for my maincore.php file that I use as a header for most pages. Here's a sample of one of the pages that uses maincore.php:

<?php
require_once ("../maincore.php");
head();
echo"<br /><br />What would you like to do in the desert?<br />";
echo '<form method="post" action="desertchoice.php">
<select name="desertchoice">
<option value="fight">Look for a Fight</option>
<option value="town">Travel to town</option>
<option value="forest">Go to the forest</option>
</select><br />
<input type="submit" value="Choose" />
</form>';
echo '</body>
</html>';
?>

Before you ask, it's not a problem with setting the cookies themselves, as both the browser at home and the browser at the school show all of the cookies with the correct names and correct values in the cookie cache. I would really appreciate it if someone could tell me what's wrong. Thanks!  ;D

Link to comment
https://forums.phpfreaks.com/topic/129900-cookies-not-retrieving/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.