Web Analytics Made Easy -
StatCounter SESSIONS counting - CodingForum

Announcement

Collapse
No announcement yet.

SESSIONS counting

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SESSIONS counting

    Hi,

    is there an easy way to count the amount of sessions currently active on my site? Users_logged_on = count($_SESSIONS); ?

    Thanks,
    twomt.
    Nemesis War
    Online browser based space combat game.
    It's free, it's great, you'll love it.
    Come join us at http://www.nemesiswar.net/

  • #2
    By default the PHP sessions are saved in files which makes any operation on multiple sessions difficult.
    You could count all files in the directory session data is stored and count the number of files but it would be inefficient especially if you're looking for particular sessions (only logged-on users for example).
    It would be best if you would store the sessions in a database by writing a custom session handler (session_set_save_handler()). There is an article on zend.com about it. You could also use my session class.
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

    Comment


    • #3
      Great tip that zend.com link, thanks very much.
      I just copied and pasted it in and hop.... implemented.

      Cheers.
      Nemesis War
      Online browser based space combat game.
      It's free, it's great, you'll love it.
      Come join us at http://www.nemesiswar.net/

      Comment

      Working...
      X