After a little more testing I have found out that it works totally fine in IE6, but FireFox 3.5 just sets the cookie whenever it feels like it. I am printing either "loggedin = 1" if the username and password matched and therefore the cookie was set, otherwise it will print "loggedin = 2" to indicate the cookie wasn't set. In my testing it will always show "loggedin = 1" when I have correctly entered a valid username and password combo, but it seems to randomly decide whether the cookie will be set. As I said earlier, IE6 always sets the cookie correctly but FireFox doesn't always set the cookie.
PFMaBiSmAd: I have read the documentation but, like usual, a lot of it typically goes over my head. The best way to learn something for me is to play with it...which leads to questions...which leads me here. Playing around with the remaining parameters seemed to get me further away.
<?php
$username = $_POST["username"];
//setcookie("grocerycookie", $username, time()+3600);
mysql_connect("_", "_", "_") or die(mysql_error());
mysql_select_db("_") or die(mysql_error());
$username = strtolower($_POST['username']);
$password = $_POST['password'];
$data = mysql_query("SELECT * FROM userpass WHERE username='$username'") or die(mysql_error());
$loggedin = 0;
while($info = mysql_fetch_array($data))
{
if ($password == $info['password'])
{
setcookie("grocerycookie", $username, time()+3600);
$loggedin = 1;
}
}
if ($loggedin == 1)
{
echo "loggedin = 1"; //the cookie should be set
}
else
{
echo "loggedin = 2";
}
?>
Try it out for yourself: http://blowthecart.com/grocery/login.php
Username: sho
Password: sho
or register your own user/pass.
Hopefully this information will help. Thanks for any suggestions.