I have two questions. I understand that if I specify the domain as .mydomain.com
(with the leading dot) in the cookie that all subdomains can share a cookie.
Simple solution
setcookie("NAME", "VALUE", time()+3600, '/', EXAMPLE.COM);
Setcookie's 5th parameter determines the (sub)domains that the cookie is available to. Setting it to (EXAMPLE.COM) makes it available to any subdomain (eg: SUBDOMAIN.EXAMPLE.COM )
Reference: http://php.net/manual/en/function.setcookie.php