If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By Bitpalace

Thread: How to check user is online or not using php?

  1. #1
    Junior Member
    Join Date
    Apr 2016
    Member #

    Post How to check user is online or not using php?

    Hello friend

    I want to know my user is online or not.

    How can I?

    Can someone give me the PHP code for it?


  3. #2
    Junior Member
    Join Date
    Mar 2016
    Chicago, IL
    Member #
    8 times
    If you only want to know how many users are currently online, try


    This will give you the number of currently active sessions. However, a session may live longer than the user is actually on site.

    If you want to know if a user is on site, you will need to follow the user from his login and track what he is doing. You will need to count the seconds from each action of the user and set your own timeout where you decide for yourself if the user is still online or not (you'd determine it by guessing that a user who has not been clicking anywhere during the past 60 seconds has probably left the site). You can also monitor login/logout activities (but many users don't logout, so this is not reliable).

    The bottom line: It is not really possible to perfectly track users unless you are monitoring all actions such as mouse movements (through JavaScript and asynchronous messages to your server), clicks, login/logout and more. There is not "PHP code" for doing that. You will have to develope your own.
    Vapr_Arts likes this.

  4. #3
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Oklahoma City
    Member #
    959 times
    Yep. This is going to be more of a front end talking to the back end thing. You'll have to track what the user is doing and periodically feed it to the backend, updating the session along the way.

    Be careful though, this kind of tracking does break some privacy laws in some countries. Some allow you a pass if you notify the user.
    Last edited by Ronald Roe; Apr 03rd, 2016 at 01:02 AM.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search tags for this page

code to check which user is online php

Click on a term to search for related topics.

Tags for this Thread

All times are GMT -6. The time now is 02:23 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: