Cookies in iframes

I’ve set cookies tons of times but never in an iframe… how do i get it to set the cookie?

example i just used to test:

setcookie("test","hello");
if($_COOKIE['test'] == "hello"){
print("it works");
}

Thanks.