how to dis visitor online(php)

Discussion in 'PHP' started by reimo, Feb 14, 2011.

  1. reimo

    reimo New Member

    Joined:
    Feb 13, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    Location:
    calabar
    please i need a help, i want a php script that help me display the numbers of visitors in my site and to display logged in users and guest.
    thank for being of help.
     
  2. underground_devil

    underground_devil New Member

    Joined:
    Jan 24, 2011
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    PHP developer ,trainer
    Location:
    Punjab
    i can make it according to need because its long script so i cant be send here :)
     
  3. ManzZup

    ManzZup New Member

    Joined:
    May 9, 2009
    Messages:
    278
    Likes Received:
    43
    Trophy Points:
    0
    Occupation:
    Production Manager:Software @ ZONTEK
    Location:
    Sri Lanka
    Home Page:
    http://zontek.zzl.org
    as this is something exactly i was doing for the past few days i can help :D
    as i figured, the best and the easiest way to achieve this is using Jscript, where a periodical updator will update the the availability of the user
    this is okay for ma chat script, but i dunno whether its okay with you, but i assure that it's mostly accurate than the previous method i used: of keeping the track of the user using a cookie and the work done by the user

    but sorry im in a kindda hurry
    so basically the logic is,
    when the user sign in-> you take him to a new page ex:homepage
    then the user is added to the online table
    and in the header of the site, you put the update code, or a jS AJAX request every 30sec. to update the time() of the database

    and peridically, add another check, mostly a AJAX request to delete the records which have the time() filed updated more than before 1 minute

    so that's it :DD
    hope you understand, and the code is rather simpler and may be you can figure it out yourself
    however ill write it seperatly later [i ave it with the core files of the chat scirpt so that it takes time to make it as standalone] :D
     
    shabbir likes this.
  4. pein87

    pein87 Active Member

    Joined:
    Aug 6, 2010
    Messages:
    173
    Likes Received:
    47
    Trophy Points:
    28
    Occupation:
    Web Dev
    Location:
    Limbo
    You need to set up either a session for every person or a cookie and have each time one is created stored in an array based on its user type. Then count each array's length for the total. Once it expires though you need to remove that index from the stack.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice