Age Gate Implementation

I’m looking at building an age-gate into a new project, but not sure on the best approach for this.

I was hoping Edge Handlers would be the solution but they’re in beta and it sounds like the beta access is currently closed. Also, the docs don’t indicate whether cookies are accessible when using an Edge Handler.

So, I am now thinking that proxying all requests via a Netlify function would work. The function would have access to check for an age-gate cookie. If the cookie is set the function can send the request to the originally requested URL. Otherwise, it would redirect to the age-gate page itself.

However, if this would be called for all incoming requests it would quickly ramp up the function usage.

Any recommendations for optimising the function usage?

hey there, lets take a step back. what do you mean by age-gate exactly?

An age gate would be the age check/pop up that is displayed before allowing you through to the website.

The site in question is selling alcohol and therefore legally needs a “Please confirm you are 18 or over before proceeding” screen.

Functions can definitely do this! Are you anticipating more than 125k unique users a month? If not, I think you’ll be just fine :stuck_out_tongue: