Hi all,
I’ve been having a heck of a time trying to get my cookies set with setcookie() to delete…
I had them deleting properly if I would exclude the path and domain arguments, but with them, they will set but not unset.
I have tried changing the time for the expiring cookie from -1, to -3600, to -960000. I’ve tried combinations of including or not including the path or domain… Nothing seems to work. I’m totally stumped.
This is happening on both IE and Firefox…
Here is the code I am using:
[code]// Checks the password with DB or else error time!
if($_POST[“password”] == “$password”) {
// This sends a cookie to tell the browser to delete itself when browser closes.
if (isset($_POST["logout"])) {
// Should have $cookie_path in this cookie, but it won't work yet.
$cookie_path="/";
setcookie("aid", "", time()-960000, "/", ".example.net", 0);
setcookie("password", "", time()-960000, "/", ".examplenet", 0);
mysql_query("UPDATE ".$COUNT_TBL["visitors"]." SET host=' ".$userinfo["id"]." ' WHERE ip = '$REMOTE_ADDR' ") or die(mysql_error());
header("Location: index.php");
} else {
// This sends a cookie that stays valid for one year
$cookie_path="/";
setcookie("aid", "$userinfo[id]", time()+3600*24*365, "/", ".example.net", 0);
setcookie("password", "$encrypted_password", time()+3600*24*365, "/", ".example.net", 0);
mysql_query("UPDATE ".$COUNT_TBL["visitors"]." SET host='".$userinfo["id"]."' WHERE ip='$REMOTE_ADDR' ") or die(mysql_error());
header("Location: index.php");
}
} else {
header("Location: login.php?error=2");
}
}
}[/code]