Cookies can be a pain when debugging. Cookies that are set on a PHP page, at the start, end or middle cannot be used in that 'load' of the page, to get the client to send cookie data to the server to be processed you will have to do a page reload. Once a cookie has been set in your browser, you either need to create a PHP script to destroy the Cookie, setcookie("user", "Alex Porter", time()-3600); - "time()-3600", or delete the browsers cookie/session data.
If you wanted to set a cookie, and use its data straight away, you should either use the variable that you used to set the cookie in the first place within the rest of your code. Set the cookie, for a page reload with header('location: page location'). Or set the data into a session aswell and call that instead.
Hope that helps a little.
/Insidus