I've got three scripts that I wrote to see if I was setting cookies properly. Here they are.
<?
//setcookie.php sets a cookie with two values (user_id and user_name)
setcookie('mycookie[user_id]', '1', '60', '/');
setcookie('mycookie[user_name]', 'joe smith', '60', '/');
echo "<a href='showcookie.php'>show cookie values</a>";
?>
<?
//showcookie.php checks to see if the cookies are set, and shows the values
if (isset($HTTP_COOKIE_VARS['mycookie[user_id]']))
{
echo $HTTP_COOKIE_VARS['mycookie[user_id]'];
echo $HTTP_COOKIE_VARS['mycookie[user_name]'];
}
else
{
echo "no cookie set";
}
echo "<br><a href='setcookie.php'>set a cookie</a><br>";
echo "<a href='removecookie.php'>remove a cookie</a>";
?>
<?
//removecookie.php removes the cookies
setcookie('mycookie[user_id]', '', '60', '/');
setcookie('mycookie[user_name]', '', '60', '/');
echo "<a href='showcookie.php'>click</a>";
?>
I'm accessing setcookie.php first then going to showcookie.php. I keep getting the "no cookie set" message even though the cookie is there. I've checked my Temporary Internet Files to verify it. Any ideas?