create a middleware that validates the age on each request. Ref https://laravel.com/docs/5.8/middleware#defining-middleware
Just make sure that your app captures your users date of birth so that you can calculate their age on the middleware.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a client that asked me to create an adult website and it's mandatory that I create an adult verification page asking the users age before continuing. How can I create a page like that?
Thank you in advanced.
Ok, so that's just a form with a checkbox with the value set to 1 instead of a date input, and you validate it with the accepted rule. https://laravel.com/docs/5.8/validation#rule-accepted
If they pass validation and you store the value in session, and then check for it in middleware for every request, then they'd only see it once assuming they checked the box. If they didn't, they'd just keep getting redirected to the age verification form no matter what url they visit (via middleware). https://laravel.com/docs/5.8/middleware
Please or to participate in this conversation.