Questions about judging whether the user is online or not!

Source: Internet
Author: User
Questions about judging whether the user is online!!!
Has been heard how to determine whether the user online this topic, has not been the essentials, today specifically to ask you!! Thank you, everyone!!

Share to:


------Solution--------------------
Log the session to the database, and also identify the user ID number, determine whether the user online to see if the ID number corresponding to the session information is expired. Do not know what I said is not right, welcome downstairs the big God shoot bricks.
------Solution--------------------
The main is to determine the last activity time, set a shorter default online time, if there is no activity record in this time is not considered the line;
------Solution--------------------
1, why should I judge whether the user is online?
Since the user is not on the line, he will not make a request to you.
Unless you have a need to show the number of people online
2, when to determine whether the user is online?
When you need to show the number of people online, it's natural that at least one user has made a request
Count the number of people online only when the request is ringing
What's the use of statistics if no one else has access to your site?
3, how to judge the user online?
Whether or not to register a user, only the number of valid sessions can be counted.
If you feel that the default session expiration period of 1440 seconds is too long, you can adjust as you want

------Solution--------------------
Log user last access time
Check the interval between the user's last access time and the current time, if beyond the agreed range, is considered not online

Determine if User A is online work is performed during User B activity
Judgment is performed independently on the server side, regardless of the client
------Solution--------------------
You can use a memory table to update the user's last operation time, and then use Cron to perform cleanup of the user's actions on a regular basis, so that the list is the most recently online user.
  • Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.