P
P
Pavel2017-02-20 14:20:15
JavaScript
Pavel, 2017-02-20 14:20:15

How to read cookies when re-entering the site?

The question is: using the jquery.cookie plugin, a confirmation window for entering the site was created, but when the page is refreshed, the window appears again. How to read cookies when you re-enter the site? code example:
var years = $.cookie("18old");
if(years != 1) {
$('#popup-wrapper').show();
}
$('.no').click(function(){
window.location.replace("");
});

$('.yes').click(function(){
$('#popup-wrapper').hide();
$.cookie("18old", 1, { expires : 30 });
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2017-02-20
@ThunderCat

Put the code in a tag.
According to the code, everything seems to be correct, which means errors are in the process of execution, respectively, use the console to catch errors, alert / console.log () to view the current state of the variables and check the script. In short, you need to debug, learn to use the brain debugging tools.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question