Age Restrictions | SoloLearn: Learn to code for FREE!


Age Restrictions

How to make a website age restricted using PHP

7/3/2020 9:02:19 PM

Ndeanaefo Chidalu

14 Answers

New Answer


Ndeanaefo Chidalu It's a simple things just compare the birthday year with current year. If difference is greater than restricted age then do not allow to register.


AJ Anant I am still a beginner


Thanks for the answer AJ Anant


it is a form for logging in


Ndeanaefo Chidalu You can go through this link to know how to get difference between two dates


Bhavya How using cookies?


Bhavya To store in cookies first we should know about the the DOB of the user. How will you store in cookies without knowing the DOB. Without making form or DOB provided by the user we can't get what is the DOB of the User. BTW Ndeanaefo Chidalu was asking at the time of sign up so there is no need of cookies because it's a 1 time activity. @Chidalu you should mention with question. We can check the age restriction on server side after asking DOB by the user.


Cood question, Thanks AJ Anant, beginners really need skilled members explanation


You can put a checkbox asking if user is above specific age when signing up then


Bhavya Cookies can be destroy so obviously we need to ask dob. Btw his question is about at the time of Sign Up. He wrongly mentioned loggin time and I don't think we need to ask every time on login because if user is already registered then why we need dob at the time of login. We can see the example of Gmail and Facebook.


Using cookies


How else will you know if the user is above some age without storing it in a cookie, or session unless you are making them sign up and login AJ Anant - C#/Java Challenger


AJ Anant - C#/Java Challenger its pretty obvious you need to ask for dob so i didn't mention it. Anyway how exactly will you restrict access to website without storing that information anywhere. Will you just ask for dob everytime the user visits the page?


You should google it for more detailed information.