Questions about determining whether a user is online!
Source: Internet
Author: User
Questions about determining whether a user is online !!! I have been hearing about how to determine whether a user is online. I have no idea. I 'd like to ask you for help today !! Thank you !! Shared to: Questions about determining whether a user is online !!!
I have been hearing about how to determine whether a user is online. I have no idea. I 'd like to ask you for help today !! Thank you !! Share:
------ Solution --------------------
Record the session to the database, and mark the user's ID number. to determine whether the user is online, check whether the session information corresponding to the ID number has expired. I don't know if I'm right. thank you for making a brick downstairs.
------ Solution --------------------
It mainly determines the final activity time and sets a short default online time. if there is no activity record within this time period, it is considered offline; on the contrary, it is considered online.
------ Solution --------------------
1. Why do we need to determine whether a user is online?
Since the user is not online, he will not send a request to you.
Unless you have a need to display online users
2. when can I determine whether a user is online?
When you need to display the number of online users, at least one user sends a request.
Only count the number of online users in response to this request.
If no one visits your website, what is the purpose even if the statistics are collected?
3. how to determine whether a user is online?
No matter whether a user is registered or not, you only need to count the number of valid sessions.
If you think the default session expiration period of 1440 seconds is too long, you can adjust it as needed
------ Solution --------------------
Record last user access time
Check the interval between the last access time and the current time. if the access time exceeds the specified range, the access time is deemed to be offline.
The work to determine whether User A is online is carried out during user B's activities
It is determined to be performed independently on the server and has nothing to do with the client.
------ Solution --------------------
You can use a memory table to update the user's last operation time, and then use Cron to regularly clean up the user, so that the table is the most recent online user.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.