There is no need to record sessionid. Do you want to use sessionid to record the last operation time of abnormal exit? The last piece of data logged in by the same user must be a logout operation 1. Normal logout, the next piece of data must be a login 2. After normal operations (add, delete, modify, check) and abnormal shutdown, the next time it must be a login operation
So the length of a login time is the current login time - the time of the previous record before the next login
However, if the user does not log in after abnormal shutdown, it needs to be processed separately. For example, the sessionid will expire if there is no operation for 20 minutes. Just check whether the last record is more than 20 minutes ago. If it is more than 20 minutes ago, it will be considered as an abnormal exit.
Give me some ideas. I personally think it is not easy to implement. (Logic processing requires PHP, and paging is also troublesome. It has to be displayed in paging according to the date, instead of paging according to the number of records taken out like limit 1 , 10. Single paging sql cannot derive the final table structure), so we can only go here....
Can I ask everyone a question? Login can be recorded, but how to record logout? The user may not actually click the logout button. If it is the web, the user can just close the browser and leave it alone. How do you know when you logged out? session?
There is no need to record sessionid. Do you want to use sessionid to record the last operation time of abnormal exit?
The last piece of data logged in by the same user must be a logout operation
1. Normal logout, the next piece of data must be a login
2. After normal operations (add, delete, modify, check) and abnormal shutdown, the next time it must be a login operation
So the length of a login time is the current login time - the time of the previous record before the next login
However, if the user does not log in after abnormal shutdown, it needs to be processed separately. For example, the sessionid will expire if there is no operation for 20 minutes. Just check whether the last record is more than 20 minutes ago. If it is more than 20 minutes ago, it will be considered as an abnormal exit.
Anyway, there must be user identification to determine which user’s behavior log it is,
When writing the log, write the time difference between each login and logout into the log, and add it up at the end?
The table can be designed like this
When logging in, the login time is recorded in the session, and the exit time is set to: login time + timeout time.
When the user is active, based on the login time recorded in the session, the exit time of that record is updated: current time + timeout time.
When exiting, according to the login time recorded in the session, the exit time of that record is updated to: the current time.
Original table (assumed):
The final generated table:
Detailed process:
Give me some ideas. I personally think it is not easy to implement. (Logic processing requires PHP, and paging is also troublesome. It has to be displayed in paging according to the date, instead of paging according to the number of records taken out like
limit 1 , 10
. Single paging sql cannot derive the final table structure), so we can only go here....Can I ask everyone a question? Login can be recorded, but how to record logout? The user may not actually click the logout button. If it is the web, the user can just close the browser and leave it alone. How do you know when you logged out? session?