...

View Full Version : cookie help



esthera
03-22-2007, 08:21 PM
I have the following code for setting cookies


<?php
setcookie("username", "me", time()+3600);
setcookie("password", "test", time()+3600);

echo "set cookies:";

?>

and for reading cookies:


<?php
echo "cookies:";
echo "<br>username:".$_cookie["username"];
echo "<br>password:".$_cookie["password"];


?>

but when I read the cookies they are showing as blank after I set them

what am I doing wrong?

Nightfire
03-22-2007, 08:24 PM
Superglobals must be used in UPPERCASE :) so it'll be

$_COOKIE["username"] not $_cookie["username"].

You should've gotten a notice saying something like
Notice: Undefined variable: _cookie

goughy000
03-22-2007, 10:18 PM
Superglobals must be used in UPPERCASE :) so it'll be

$_COOKIE["username"] not $_cookie["username"].

You should've gotten a notice saying something like
Notice: Undefined variable: _cookie

unless notice are turned off which they often are =]



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum