...

View Full Version : Echoing variable from a cookie



SDP2006
10-04-2003, 03:55 PM
I've known how to do this, but It keeps leaving my memory.

I set the cookie

<?php
$yours = $_POST['name'];
setcookie("thename",$yours,time()+31536000);
echo "The cookie has been set. It will remain for one year unless you delete the cookie. If you delete it, you will have to come back here to reset it!";
?>

and then check for it and echo it

<?php if(isset($_COOKIE['thename'])){
echo 'Welcome'.$_COOKIE['thename'];
}
else{
echo "Welcome!";
}
?>
It is just echoing Welcome! if when the cookie isset...

All help is sincerely appreciated...

Nightfire
10-04-2003, 04:04 PM
If nothing's being echo'ed, then $yours isn't being set into the cookie

SDP2006
10-04-2003, 04:35 PM
It is being set in the cookie
<?php
$yours = $_POST['name'];
setcookie("thename",$yours,time()+31536000);
echo "The cookie has been set. It will remain for one year unless you delete the cookie. If you delete it, you will have to come back here to reset it!";
?>

missing-score
10-04-2003, 09:00 PM
your best bet is try

setcookie("thename", "test value", time()+3600);

then see if anything is output



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum