im having real strange problems managing my cookies, i se cookies to identify users who log on to my website, when the user presses logout a function is called which should unset the cookie. This worked when i was runing my machine off a localhost but since i have moved it on to a server there seems to be a problem. now either the system does not log the off or sometimes it randomly does!! ive tried making the cookie time invalid by a longer period etc. but doesnt seem to work!
heres my code for logging out (its a online car website thus car cookie details are unset):
Code: Select all
<?php
if ($page == "logout") {
//! possible issue here. Seeing users still logged in after pressing logout.
//! Instead of deleting cookie, going to try setting it to an incorrect value.
$cookietime2 = time()-60*-60*-24*-30;
setcookie("passhash","0",$cookietime2);
setcookie("userid","0",$cookietime2);
setcookie("manufacturer");
setcookie("series");
setcookie("model");
setcookie("year");
$_COOKIE["passhash"] = "0";
$_COOKIE["userid"] = "0";
$_COOKIE["manufacturer"] = "";
$_COOKIE["series"] = "";
$_COOKIE["model"] = "";
$_COOKIE["year"] = "";
unset($_COOKIE["userid"]);
echo "<center>Logged Out Successfully!</center>";
die ("<meta http-equiv="refresh" content="1;URL=index.php">");
?>ps. im a bit of a newbie guys so pleae explain thing throughly, thank you in advance to thoe who try to help.
sak