Cookie on submit and on close modal

Hi, I have a code that stores a cookie for a day when the modal is closed which works but I also want to add the code where once I submit form it stores a cookie forever but it doesn’t work. below is the code(it works with the submit part as comment).

//modal cookie
	var cookieName = 'modalClosed';
  if(typeof Cookies.get(cookieName) !== 'undefined'){
		//Cookies.set(cookieName, 'forever', { expires: 360 })
    $('.signup_close-button, .signup_background-overlay').on('click', function(){
    		Cookies.set(cookieName, 'stored', { expires: 1});

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


The problem might happen as in the commented code you’re using arrow function syntax (() => {}). This expression is a bit limited and might cause some errors, so if you’re not fully aware of how it works, it’s safer to use the function expression

Try to rebuild the arrow function to a normal one so it looks as follows:

$('.signup_form-block').submit( function() {
Cookies.set(cookieName, 'forever', { expires: 360 })

If you need any further help with implementation, feel free to reach us here:

1 Like

thanks this worked! this ) was missing at the end.