SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best way to count logged on visitors? php5/session/objects

    Anyone know? do i really need to create a new table which will store logged on members?
    I would appreciate if someone had a better way.


    Best Regards
    Trevors

  2. #2
    SitePoint Addict evertcollab's Avatar
    Join Date
    Apr 2006
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That way worked for me..

    I overrided the default session handlers to work from a mysql tabel. So this is the place where all my sessions are stored..

    Evert

  3. #3
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,608
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I typically use a table to store logged on users. I update this table with the timestamp on their every page load. I also run a universal garbage collection script to log out inactive users whose timestamp is greater than, say, 20 minutes old. This kills old sessions and help maintain an accurate count of logged on users.
    Ian Anderson
    www.siteguru.co.uk

  4. #4
    SitePoint Addict evertcollab's Avatar
    Join Date
    Apr 2006
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's also how I did it.

    if made a small script that generates a random number between 1 and 100, if the number is 1 it will start garbage collecting. If your usercount is low you might want to reduce that value..

    This method has worked pretty well for me (and you don't need CRON)

    Evert

  5. #5
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,933
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by siteguru
    20 minutes old.
    Whoever heard of someone looking at a webpage for 20 minutes?

  6. #6
    SitePoint Addict evertcollab's Avatar
    Join Date
    Apr 2006
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess that was a more general system, for a management app i would want a longer timeout


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
  •