Here the modal window is initially displayed, and when you click on the button it disappears, at the same time the necessary cookie is set. When you refresh the page, the window, of course, does not appear. If you refresh the page in a minute (the time of the cookie), the cookie will be deleted and the modal window will reappear.
<html> <head> <meta charset="utf-8"> </head> <body> <!-- Модальное Окно --> <div id="overlay" style="border: 1px solid black;"> <div class="popup"> <p>текст</p> <button id="hide_popup" class="dont-show-me">больше не показывать</button> </div> </div> <script> function getCookie(name) { let cookie_arr = document.cookie.split('; '); let cookie_obj = {}; for (let i=0; i<cookie_arr.length; i++) { let nv = cookie_arr[i].split('='); cookie_obj[nv[0]] = nv[1]; } return cookie_obj[name]; } let overlay_div = document.getElementById('overlay'); if ( getCookie('hide_popup') == 'yes' ) { overlay_div.style.display='none'; } // При нажатии на кнопку ставим cookie, которая будет запрещать показ // модального окна document.getElementById('hide_popup') .addEventListener('click', function() { // Ставим cookie на минуту. var date = new Date(new Date().getTime() + 60 * 1000); document.cookie = "hide_popup=yes; path=/; expires=" + date.toUTCString(); // и сразу же скрываем окно overlay_div.style.display='none'; }); </script> </body> </html>
More information about working with cookies on JavaScript can be found here .