Hi guys,
When a user types a correct username and password format into a form, it sets a cookie:
<?php
if ($userbox=="Mike" AND $passbox=="Ace" ){
setcookie("loggedon", "1", time()+3600) && header("location: [url]http://www.gawmir.com/members/members.php[/url]");
setcookie("username", "$userbox", time()+3600);
}
?>
I have then made it so on another page, it says what the username of this person is - by doing:
<?php
if (!isset($_COOKIE['username']))
{
echo "Not logged in.";
}
else
{
echo ($_COOKIE['username']);
}
?>
On that page (which is in the same folder as the file which sets the username cookie) it says your username - which is what it is supposed to do when you go onto it if you have logged in.
However, on a file in a different folder to the one that sets the cookie - I have the exact same code as above, apart from a load of HTML below it. The outcome of this one is "Not logged in".
Please could someone help here, I have no idea what the problem is😕
Cheers,
Mike🙂