I am planning on storing a cookie with a user's name. But if i make a logout option is there anyway I can delete, or unset the cookie? The way i decide if a user is logged in is see if the variable exists, and if it does it simply echos the value for that variable. From what I've read it doesn't seem like there is a way to delete cookies.
Thanks for any help.
so you want to unset the variable/cookie 🙂 it's very ironic that unset() is a built in function, just go like this: unlink($username); and it'll delete teh cookie, now if you wanted to do it differently, you could just set the cookie to "" (null)
I've tried the unlink method and it says that the unlink failed. In the documentation it says that the parameter has to be a file, not a variable name. And as for the setting it to "" the variable will still be set, it will just be an empty string. That is completely different from NULL. Don't get the two confused. They don't mean the same thing. Thanks for trying though
No, not UNLINK, UNSET. UNSET($variable);
http://www.php.net/manual/en/function.unset.php
🙂
or try setcookie("variable_name") to delete the cookie on subsequent pages
kind regards
paul