Answer the question
In order to leave comments, you need to log in
Checking for cookies after assigning them?
I have a window which, after opening, sets cookies, but after closing it, it can open again even if there are conditions for the presence of cookies. How to make a check so that everything happens in real time, that is, without reloading the page?
function getCookie(name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : undefined;
}
var alertwin = getCookie("alertwin");
if (alertwin != "no") {
$(document).mouseleave(function (e) {
if (e.clientY < 10) {
$(".pop-up-exit-wrapper").fadeIn("fast");
$(".bg-flt").fadeIn("fast");
var date = new Date;
date.setDate(date.getDate() + 1);
}
});
}
$(".close-btn,.bg-flt").on('click', function () {
$('.pop-up-exit-wrapper,.bg-flt,.pop-up-timer-wrapper').fadeOut();
document.cookie = "alertwin=no; path=/; expires=" + date.toUTCString();
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question