PHP - Conditionally displaying content based on cookie not working in all browsers

I am setting a cookie using PHP and then if the user comes back to the page I am conditionally displaying content based on if that cookie is set. This is working on some desktop browsers(Chrome and Firefox), but it is not working on Safari or IE or on any of the mobile browsers I've tried(Mobile Safari, iOS FireFox). I used Safari developer tools to confirm that the cookie is being set in mobile safari, but it seems to be ignoring the condition. Any ideas?

Here is how I am setting the cookie:

setcookie('viewed', true, time()+86400*365, '/');

And here's the conditional display:

<?php if(isset($_COOKIE['viewed'])) { ?>
Page has been viewed
<?php } else { ?>
Page has not been viewed
<?php } ?>