How to make a cookie be on the whole site instead of being on a specific page/

Try setting a path and domain,

setcookie('style', 'style2', time()+31536000, "https://wordpress.stackexchange.com/", '.example.com');

Replace .example.com with your sites hostname.

Further reading: http://php.net/manual/en/function.setcookie.php