Here is a basic piece of PHP to do this.
Set the cookie...
PHP Code:
setcookie("Cookie", '1', time()+3600, ".yoursite.com", 1); //Cookie will expire in an hour. Change to your needs...
Check to see if the cookie is set...
PHP Code:
if($_COOKIE['Cookie'] == '1') {
echo 'You\'re not allowed to see this!;
}
else {
//Execute code as normal...
}
Ive not tested it but the basic princibles are there.
http://uk.php.net/manual/en/function.setcookie.php