Streaming live at 10am (PST)

Set cookie on form submit

Hi,

I am trying to setup a link to a downloads page, but only after they have submitted their e-mailadres.
On submit I would like to set a cookie so the users doesn’t have to rein put their data every time they visit that section…

Any idea on how I can set that up?

Tnx


This is the method that worked for me:

<script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>

<script>
	var cookieName = 'yourCookieName';

	if (typeof Cookies.get(cookieName) !== 'undefined') {
		$('.class-name-of-form').remove();
	}
//below sets the cookie on sumbit and removes the modual the form is in staright away
	$('.class-name-of-form').submit(()=>{
		Cookies.set(cookieName, 'value', { expires: 180 })
		$('.class-name-of-modual').remove();
	})
</script>

I also set the fields in my form to [name and email] to required.

Hope this helps.