J
J
jrborisov2016-03-25 17:20:42
PHP
jrborisov, 2016-03-25 17:20:42

Timed user role change in mysql?

There is a tbl_users table in the database that stores information about users, this table has a user role field (let's say 1 - user, 2 - moderator, etc.).
There is a table of privileged users, which stores the user id and the time for which it was given (let's say a month, that is, until 03/25/2016).
and it is necessary that after this time the user's role has changed from privileged to normal.
while in ideas to check users (privileged) when they climb the site and if the date has expired, change its role. but as I understand it, this is not economical .. if you have any ideas, tell me

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DuD, 2016-03-26
@jrborisov

There are 3 options:
1) Check the expiration at login. Quite economical and works. But if the session hangs on the site for a long time, then you can miscalculate and the user will not lose his role.
2) Check the expiration on each request to the site, well, this can really be a little expensive. But the accuracy will be on top.
3) It seems to me the most correct. cron job that checks all records according to the schedule and blocks if necessary.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question