Looking for some advice on the best way to code up an age gate (similar to this https://driftlessglen.com/ )
I am looking to store a variable in sessionStorage that will be set on click and remove the overlay that houses the age verification content. Allowing viewers to interact with the website. Once they return the sessionStorage would be cleared and they would be asked to verify age again.
Hey @osully93! Hope you’re well. Welcome to the community!
I actually assisted @myonke with this (almost) exact task a few weeks back!
The difference is that I used Local Storage, as Michael wanted the user to have to re-confirm after 1 month. However, your approach is easier and you can modify the gist of code linked in the post to match what you need. (Replace every instance of localStorage in my code with SessionStorage - everything else will be the same.)
Also, you can remove any instance of “moment”, “expire”, or anything else that has to do with time in that snippet of code. (Including the very first line of my script where I reference the moment.js library - a library that makes dealing with time easier)
Those were solely for the purpose of expiration after 1 month. You only need the WF Permission lines.
I edited your script to remove some unnecessary values (time related things), but yes, it should work!
You should note that the script references IDs, so you’ll have to give your elements the same IDs (Like a “yes I am 21” button an ID of “btnYes”) OR change the script to match your existing IDs.