I've been learning how to use cookies, I've had a similiar problem.
I use the setcookie(name, value) function to write them, and the $HTTP_COOKIE_VARS[name] to read them.
I've noticed that
If you're writing to a cookie straight from the url variables, such as:
setcookie("username", $HTTP_POST_VARS["username"]);
will write a blank cookie (and so, delete it).
but, if you buffer this variable, it'll work. An example:
$UName = $HTTP_POST_VARS["username"];
setcookie($username, $UName);
Hope this helps..
neur0maniak