Issue
I am fairly new to mysql.
I am creating a login system, and I want to create a reset password option for the user. Every time the user requests for a password reset a code is created and I want to reset this code every 12 hours after it has been created.
I am running a LAMP
server on a raspberry pi 3
Solution
One simple approach would be to also maintain datetime column in the user table, which records the server time when a particular reset token were created. Then, in your database logic, you would compare that timestamp against the current time, and assert that no more than 12 hours have passed. If the token has expired, then just return NULL
from your query, and then handle the NULL
value in your server side application logic as a failure.
I don't recommend trying to configure MySQL to manage this logic (though it might be possible to do so). A database is designed to store data, not so much to manage it, the latter which is the responsibility of the application, or maybe a DBA.
Answered By - Tim Biegeleisen