Check the manual fot this issue. You will see that the 3th parameter you can give with setcookie() is the expire parameter.
setcookie ("cookie", $UID,time()+86400);
Will set a cookie for a day.
BTW if you, for instance, set a cookie for an hour it may expire on the fly because your server is in new york and your visiter is in london. London is ahead 4 hours if i'm not mistaking.
Other solution:
If your able to alter the php.ini file you can set session.cookie_lifetime = 0
This way the cookie will expire at the moment the browser is reset.
PS: You can use ini_set() to do this:
ini_set ("session.cookie_lifetime", "0")
Don't know if this works, didn't test it.