SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Member
    Join Date
    Jan 2004
    Location
    boston
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can anyone suggest a good REAL TIME who's online script?

    Im looking for a good, working, accurate Whos Online script. I have tried a few but they do not appear to be accurate in testing them. I looking for something thats real time and not every few minutes or so.

    thanks in advance for any and all suggestions.

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    theres a couple factors to consider.

    normally, a user is considered "offline" when they either logout, or have not requested a webpage in x minutes.

    around 10-15 minutes is a common value for x, although it can be whatever you want.

    most users dont "logout" so most of the time you will be going off of how long they have been inactive to determine whether they are still online or not. you could reduce the window to a minute or even 30 seconds or less if you want, but this will now indicate users as being offline if they are reading a large page, or just went to make a cup of coffee etc...

    the only semi accurate way to get accuracy with such small intervals is to force them to constantly re-contact your webserver to let you know they are still here. this could be done with javascript by making it continually request an image just send a get request, or with a small hidden iframe that is set to refresh every few seconds. of course you will need fallback functionality for those browsers which wont obey your javascript or constant iframe refeshes.

    then you can update your database each time they check back in with your webserver. this would create a large amount of web requests to your server, as well as a lot of database updates. the load could become fairly large on a popular website.


    then comes the matter of generating the results. ideally for efficiency, you generate the whos online list once every few minutes, and cache the result. but if you want to regenerate it for every page view so its "real time", this could again start to add large amounts of overhead.

    so yes you can do it, but it will be more complicated and it will definately add much more overhead.

  3. #3
    SitePoint Member
    Join Date
    Jan 2004
    Location
    boston
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no suggestions for an actual script with that?

  4. #4
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    USA, Saratoga Springs, NY
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    His reply was more of a "it depends on your situation and exactly what you want to do, along with your specific server allowances"...so you need to do a bit more research to determine exactly what it is that you want/need.
    They say, "Practice makes perfect," yet they also say, "Nobody's perfect". I don't get it.

  5. #5
    SitePoint Member
    Join Date
    Oct 2006
    Location
    Beirut, Lebanon
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.sim-php.info/users-online-script.php is probably what you are looking for.
    Last edited by josephkiwan; Nov 13, 2006 at 02:45. Reason: Spelling error.
    Lebanon

  6. #6
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    To be honest, there is no such thing as real time on the web. The moment the browser has to go out onto the web to fetch new data you lost the real time. Even with a high-speed connection its just far too slow.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  7. #7
    SitePoint Addict telos's Avatar
    Join Date
    Mar 2005
    Location
    192.168.2.34
    Posts
    279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth
    To be honest, there is no such thing as real time on the web. The moment the browser has to go out onto the web to fetch new data you lost the real time. Even with a high-speed connection its just far too slow.
    But AJAX can help that. You probably don't want a script updating every half-second. But updating every couple of seconds might not be a bad idea (depending on the size of the request).

  8. #8
    Resident Code Monkey Chris Corbyn's Avatar
    Join Date
    Nov 2005
    Location
    Melbourne, Australia
    Posts
    713
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by telos
    But AJAX can help that. You probably don't want a script updating every half-second. But updating every couple of seconds might not be a bad idea (depending on the size of the request).
    You don't even need AJAX. Just a simple JavaScript Image() object and keep changing it's src property to a PHP script on the server with a few args. AJAX is obviously better though so that the browser doesn't pause while the request is made. You are of course ultimately relying on JS though, but you can always fall back on the time of the last full page request.

  9. #9
    SitePoint Addict
    Join Date
    Jul 2006
    Location
    Kansas City, MO
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That users online-script is really, really poor coding.

  10. #10
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, it even has an sql injection hole.

  11. #11
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by d11wtq
    You don't even need AJAX. Just a simple JavaScript Image() object and keep changing it's src property to a PHP script on the server with a few args. AJAX is obviously better though so that the browser doesn't pause while the request is made. You are of course ultimately relying on JS though, but you can always fall back on the time of the last full page request.
    It still has to go though the network, to the ISP, and if you are lucky to the internet, then a DNS server, lot more gates, then to the server, then the server has to process the request, etc. So no matter what you do there is no real-time on the web no point in even trying.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  12. #12
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    USA, Saratoga Springs, NY
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to get stupid-technical about it, you could always introduce the lag time between the optical perception from the eye to the brain, compared to when an event actually happens..........
    They say, "Practice makes perfect," yet they also say, "Nobody's perfect". I don't get it.

  13. #13
    SitePoint Addict telos's Avatar
    Join Date
    Mar 2005
    Location
    192.168.2.34
    Posts
    279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whether or not it is real-time is not the point. What matters is if it is perceived as real-time.

    Perception is everything.

  14. #14
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    USA, Saratoga Springs, NY
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you want the blue pill, or the red pill? :P
    They say, "Practice makes perfect," yet they also say, "Nobody's perfect". I don't get it.


Bookmarks

Posting Permissions

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