So I've created a simple tip box that fades in on page load, with an option to close the box. I'm trying to make the box hidden if the visitor clicks the close link. I'm fairly new to cookies, so I'm probably doing it all wrong, but this is what I have:
$('#close').click(function(e) {
jQuery.cookie('tip', 'hide', cookieOpts);
$(this).parent('div.tip').fadeOut(1000);
e.preventDefault();
});
jQuery.cookie('tip', 'show', cookieOpts);
$('.tip').delay(500).fadeIn(1000);
var shouldShow = jQuery.cookie('tip') == 'show';
var cookieOpts = {expires: 7, path: '/'};
if( shouldShow ) {
$('.tip').delay(500).fadeIn(1000);
}
else {
$('.tip').css('display', 'none');
}