Help, please, make updates to the user, that is, if he does not have activity for some time, it means to throw him out.
- Do you keep any statistics on the last visit by the site user? And what does “throw out” mean? - DemoS 2:22
- 2Nothing is clear! Where to throw? From the window? Termination of the session on timeout? - Gorets
|
2 answers
In general, if you need to manipulate users, then it is better to make your sessions in the database + this will solve the clustering problem.
In the session table there will be last_action_time which you will update on each request.
Well, the "throw out" users will be:
"update session set state='closed' where last_action_time < ".(time() - 60*5);
|
Zapulit row 'last_visit` in the table with users and record the last visit to it! Make a calculation at the right time and delete inactive by entering the value 0 into the 'user_active' line.
- Once a month, make a check on this table column, if the difference is the current date minus the last visit date is more, for example, half a year, then delete it - Gorets
|