Next time, please post what error message you're getting. From your code, it looks like you're almost certainly getting the "Headers already sent" error. That's because you're sending output to the browser (echo) before you set the cookie, which is a no-no (this is covered thoroughly in the documentation, btw).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.