I've been trying to set this up for a while but i can't seem to get it right. My goal is to make the newsletter appear once only if the user hasn't visited the site. The problem i run into is that the cookie is set but the pop up is still showing. I have looked all over stackoverflow and i've been tweaking code but can't seem to make it work. Any ideas why?
<?php
if (!isset($_COOKIE['visited'])) {
setcookie('visited', true, time() + 3600 * 24); // Save a cookie for 1 day
?>
<div class="newsletter_pop">
<div class="pop-contain">
<p class="close-new-pop">x</p>
<?php echo $this->getLayout()->createBlock('newsletter/subscribe')>setTemplate('newsletter/pop.newsletter.phtml')->toHtml() ?>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function($){
$('.newsletter_pop').fadeIn();
$('.close-new-pop').click(function(){
$('.newsletter_pop').fadeOut();
});
});
</script>
<?php
}
?>