In a MySQL Database I am building, I have a column where there is a simple 0 or 1 (true or false) data field. All data is initially set to 0. If a user presses a button on the website I am building, it will change (in the database) from 0 to 1 to show the user as Logged in. I want them to be automatically Logged out by the end of the day (Again, this is accomplished by setting them to 0).
Here is the question: Is there a way to “expire” data after a period of time and set it back to default (or 0)? If so, can it be based on a specific period of time?
If there is any SQL command or method to do this, what about PHP?
Without triggering a procedure you may be out of luck here. However, why don’t you do the following: instead of a Boolean use a date and set the date on login. Then, instead of asking if login is true, ask if the login date is the current date. No expiration cleanup necessary, problem solved.