I am hoping someone could help me with some custom code that if the viewer is 19 or older, the viewer can access the website for 30 days. If they are younger than 19, the Age Gate page remains and the viewer cannot access the website (similar to this https://www.qwestcannabis.com/
I created an Age Gate page but that is as far as I can get.
@ambergeron - check out this tutorial by @vincent on setting cookies in Webflow:
Basically when the user inputs the form with their birthdate, you need to calculate if they meet your criteria (great than 19 years old) and then set the cookie value, maybe something like this:
<script>
$(document).ready(function(){
if (userAge > 19) {
var date = new Date();
date.setDate(date.getDate() + 30);
$.cookie('ofAge', true, { expires: date });
}
});
</script>
Thank you for the info @sam-g. I re-created my age gate in a new project using tutorial by @vincent. Unfortunately, I am still having issues though… On the published site, once I enter a date of birth, nothing happens… I am pretty sure it must be the code i put in the Before tag.
Thank you @webdev for the feedback. I checked my browser console and see that it is the userAge that is not defined. I have no clue how to code/define this. Would you be able to guide me?
@ambergeron - you’re going to need to define this yourself when the form is submitted. You’ll need to get the users birthday and compare it to the current date when the form was submitted to get the age (in years in this case)