We built a notification with fancybox that needs to be shown to all of our users once but currently it's showing once on every page of the site and setting a cookie for every page the visitor visits, our code is as follows:
// jQuery Cookie popup
$(function() {
if ($.cookie('cd-notification-cookie')) {
// it hasn't been three days yet
} else {
$.fancybox.open([
{
href : '#notification'
}
], {
maxWidth : 420,
maxHeight : 800,
fitToView : false,
width : '90%',
height : 'auto',
autoSize : false,
closeClick : false,
closeEffect : 'none'
});
// set cookie to expire in 3 days
$.cookie('cd-notification-cookie', 'true', { expires: 3});
}
});
Is it possible to set a global cookie for the whole website instead of a per page basis?
You can try to set the path to the base of the application like
$.cookie('cd-notification-cookie', 'true', { expires: 3, path: '/'});