Are you over 18?

Having worked in the Specialist Tobacco industry for over 15 years, all online Tobacconists have hoops to jump through. One of the biggest problems is stopping underage viewers from visiting the website. A simple “Are you over 18” popup is a start at doing this, although it wont save a retailer from fines if they are caught selling underage.

This is a simple solution I have used on my own websites and on others, this can also be used to show news letter signups or adverts. By placing the code snippet somewhere on every page, means people cant avoid it, regardless of which page they land on. I tended to put this in the footer, so the images or text are not included on any social media share or search engine results.

This solution makes use of “js cookie” by Klaus Hartl & Fagner Brack (

What happens?

  • After the HTML is generated, the JS checks if the cookie has been set. If it has, it hides the HTML.
  • If not set, the over 18s notice will fill the screen and ask if you are over 18 or not .
  • If you click yes, the notice will be hidden but also a cookie is set, so the next time it is loaded, it will be auto hidden for 7 day. (Clicking no takes the use to google)

Post comment