Cookies and localhost

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
homerwells
Forum Newbie
Posts: 4
Joined: Fri Mar 21, 2003 9:26 am

Cookies and localhost

Post by homerwells »

Do cookies work on personal servers? I'm trying it out and it doesn´t seem to work. Is there any special configuration that should be worked on for them to work?
Thanks,
Leo.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

They should work - what does your code look like?

Mac
homerwells
Forum Newbie
Posts: 4
Joined: Fri Mar 21, 2003 9:26 am

Post by homerwells »

<?

setcookie("cookie[login]", true);

?>

then in a different file, same dir:

<?

if ($cookie['login'] == true)
echo "LOGADO";
else
echo "NÃO LOGADO";

?>

the error is:

Notice: Undefined variable: cookie in c:\web\labic\gerencia\teste_session2.php on line 3
NÃO LOGADO
sleepingdanny
Forum Newbie
Posts: 12
Joined: Thu Mar 20, 2003 4:27 am
Location: Israel

Post by sleepingdanny »

Try to upload the 2 files that you told us to your site... OR maybe the code can't work because it should look like this :P :arrow:

Code: Select all

<?
setcookie("login")
?>

Code: Select all

<?
if(isset($_COOKIE["login"])){
print "Logged In";
}
else{
print "Not Logged In";
}
?>
Post Reply