Page 1 of 1

Cookies

Posted: Mon Nov 24, 2003 8:46 am
by Straterra
I can properly set a cookie, but I cannot retrieve it. I get the error of Notice: Undefined index: testcookie in c:\ftp\users\straterra\cgi-bin\getbox2.php on line 2. The code for my cookie retrievel is
<?php
$cook = $_COOKIE['testcookie'];
echo $cook;
?>

And the code for saving the cookie is
<?php
$song = $_POST['dropdown'];
setcookie ("testcookie", $song);
echo $song;
print_r ($_COOKIE);
?>

If anyone could help, I would greatly appreciate it.

Posted: Mon Nov 24, 2003 9:36 am
by twigletmac
Do you refresh the page in between setting the cookie and trying to echo it's value?

Mac

Posted: Mon Nov 24, 2003 3:56 pm
by Straterra
Yes, I do

Posted: Tue Nov 25, 2003 5:49 am
by twigletmac
Do you get anything if you do:

Code: Select all

print_r($_COOKIE);
on the second page?

Mac