I'm trying to make a splash screen appear only the first time someone visits a Wordpress site. I don't know much about PHP but setting and reading a cookie seemed like an easy way to do this, so I added this to the header.php:
<?php if ( !isset($_COOKIE['accessed']) ) {
setcookie('accessed', 'yes', time() + (86400 * 30)); // 30 days
?>
<script>
// Some code
</script>
<?php
}
?>
The script runs but the cookie never get's set so it runs on every visit...
I read somewhere that you can't set and read a cookie on the same page with PHP, but if that's true then I really don't know how should I implement this.
Any hint would be really appreciated!