Newsletter modal + cookies

Hello,

I’m using a newsletter modal.

The code i’ve used clears cookies every 30 days so the user sees the modal again even if they have subscribed. Do you know how to store a cookie to hide the newsletter if the user has successfully subscribed so they don’t see the sign up again?

Here is the code i’m using i found here. I don’t have code knowledge so i’d appreciate any help.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
<script>
$(document).ready(function(){
  window.interval = 90 * 1000; // milliseconds.
  window.poll_interval = 5 * 1000; // milliseconds again
  var now = Date.now(); 

  function checkPopup() {
	var now = Date.now(); 
    console.log((90 - ((now - $.cookie('alert-timer')) / 1000 )) + "s till popup" );
 	if(!$.cookie('alerted')) {
	  	if ((now - $.cookie('alert-timer')) >= window.interval) {
	    	$('.popup-overlay').show();
	    	$.cookie('alerted', true, { expires: 30});
	    	clearInterval(window.poller);
	  	}
	  }
  }

  if (!$.cookie('alert-timer')) {
    $.cookie('alert-timer', now, { expires: 30 });
  }
  
  // Check every 3 seconds
  window.poller = setInterval(checkPopup, poll_interval);
});
</script>

Thank you


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

Any code geniuses have an idea?