I'm am having some trouble with cookies.
I can set the cookie and view it on the same page, but I have not been able to get another page (in the same directory) to access the cookie.
Here is my code:
and here is the code on the test.php pagePHP Code:<?php
$c_data = "[Your Name]";
if (setcookie("cookietest", $c_data, 0, "/", "", 0) == FALSE)
{
print "There was an error while attempting to set the cookie.";
exit(0);
}
else
{
print "The cookie was set to $c_data successfully.<br>";
if (isset($_COOKIE["cookietest"]))
{
$c_data2 = $_COOKIE["cookietest"];
print "I see the cookie as being set to $c_data2.";
}
print "Click <a href=\"test.php\">HERE</a> to test the cookie on another page.<br>";
exit(0);
}
?>
Any ideas on why this is not working?PHP Code:<?
if (isset($_COOKIE['cookietest']))
{
print "Are you " . $_COOKIE['cookietest'] . "?";
}
else
{
print "The cookie could not be found.";
}
exit (0);
?>
Thanks,
Squirrelly1




Life is grand for a coder, no?
Reply With Quote