I should just post the whole chunk:
if(!isset($_COOKIE['homepage'])){
$rand = rand(0, 1);
if($rand == 0){
setcookie('homepage', 'home', time()+60*60*24*365);
} else {
setcookie('homepage', 'buy', time()+60*60*24*365);
header('Location: /buy/');
exit;
}
} else {
if($_COOKIE['homepage'] == 'buy'){
header('Location: /buy/');
exit;
}
}