Jump to content

Cookies will NOT delete.


marcus

Recommended Posts

Ok. What I'm doing is checking to see whether the UID and Encrypted Password combination is correct.

 

if($need_log > 0){
$sql = "SELECT * FROM `users` WHERE `id`='{$_COOKIE['uid']}' AND `password`='{$_COOKIE['cpp']}'";
$res = mysql_query($sql) or die(mysql_error());

if(mysql_num_rows($res) == 0){
setcookie("uid","",time()-314496000);
setcookie("cp","",time()-314496000);
setcookie("cpp","",time()-314496000);
unset($_COOKIE);
header("Location: /index.php");
}
}

 

It does redirect the user to the index but the cookies remain unchanged and have the same values in the end. That's the exact code I have when the user wants to log out, and that works, but the code checked here does not work.

Link to comment
Share on other sites

Is this code being executed from a different path? I know cookies are pretty sensitive, so if you set them in /subpath/subpath2, then try to delete them from root or /subpath, it may not work. If you're not setting the path parameters explicitly when the cookie is created, try doing that, then stating the same parameters when you delete them. If that doesn't work, I don't have any idea what the problem might be. It seems strange that the deletion works on logout but not there.

Link to comment
Share on other sites

Hm. So you're setting the cookies with setcookie("uid", [id], time() + 60*60*24*365, "/"). Did you try deleting it with setcookie("uid", "", time() - 3600, "/")? I didn't pick up from your post whether or not you're operating in the same path with both calls to setcookie(). That would certainly make a difference.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.