<?php setcookie('userid','AAA'); ?> <html><head><title>Page with cookies</title><head> <body> This page sets a cookie properly, because the PHP block with setcookie() in it comes before all of the HTML. </body></html>