I have a web app which users login to it.
Every time a specific user logs in, I store the login datetime in a MySQL db:
(yyyy-mm-dd hh-mm-ss)
Each record in the db has a user_identifier and last_login_datetime.
However, I want to make sure that users can only login once a day.
I was thinking about comparing the time function in PHP to the datetime I have in the DB and see if the user was already logged on today.
If the user was logged on today, I’ll kick him out.
How do I compare the record in the DB to the time function in PHP to see if the user was logged in already?
Thanks!
You might add something like this to conditions of the
SELECTto validate a user’s credentials when they loginIf the day, month, or year do not match today’s day, month, and year, the select will return the user (assuming the other credentials/conditions are valid). If no result is returned, the user’s credentials were incorrect or the user has already logged in today – either way they should not be allowed to login according to your requirements.