jQuery modal cookie warning window


In the article, we will look at how to make the jQuery modal PopUp warning window when you first start the site using a cookie to store a variable, by which you can determine whether the user has previously visited the site and what choice he made. The logic of the pop-up window is as follows: when the site is first launched, a PopUp window pops up with a condition, for example, we ask the user if he is 18 years old.



If he just closes the site and opens it again, the window will still drop out until he makes a choice. If he selects “NO” – a record will pop up that you need consent to view the site or you need to leave the site.

Thus, the window will drop out all the time and prevent it from doing any actions with the site until the user agrees. If the user clicks “YES”, thereby agreeing that he is 18 years old, the window will no longer drop a certain number of days, which we indicate in the script.


Html code modal (popup) window:

Code of css:

code jQuery script:

The expires parameter specify the number of days to store the variable in the cookie

Connect jQuery and cookie library



Please enter your comment!
Please enter your name here