How to make a website age restricted using PHP
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 https://www.google.com/amp/s/www.geeksforgeeks.org/how-to-calculate-the-difference-between-two-dates-in-php/amp/
Bhavya How using cookies?
Cood question, Thanks AJ Anant, beginners really need skilled members explanation
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.
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.
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.