Opened sessions

Discussion in 'PHP' started by nebhotep, May 28, 2008.

  1. #1
    Hi

    Is there any posibility to find out how many php sessions are currently open on my site? My users log in using session, and I want to know how many of them are online
     
    nebhotep, May 28, 2008 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    Count the number of files present in sessions directory. It is normally /tmp. You can confirm the session path from php.ini.
     
    mwasif, May 29, 2008 IP
  3. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Although, that's all opened sessions on a server, not a single site.
     
    jayshah, May 29, 2008 IP
  4. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #4
    You are right. I assumed the site is running on a dedicated server. Then the only solution which I can think of is to use database driven sessions on your site.
     
    mwasif, May 29, 2008 IP
  5. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #5
    Thanks :) The best way is to change the code to simple log this information (last page, time, etc.) then have another page parse this data for active users over the last x minutes.
     
    jayshah, May 29, 2008 IP
  6. nebhotep

    nebhotep Active Member

    Messages:
    244
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    80
    #6
    thanks guys. I have decided to create a database based script to get the number of users online, I have already make some tests and it seems to do the job
     
    nebhotep, Jun 1, 2008 IP
  7. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #7
    Using database driven things increase database activity but extremely useful :)
     
    mwasif, Jun 1, 2008 IP
  8. nebhotep

    nebhotep Active Member

    Messages:
    244
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    80
    #8
    you're right, but can have no results with no effort
     
    nebhotep, Jun 2, 2008 IP
  9. InFloW

    InFloW Peon

    Messages:
    1,488
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Make sure to make it a memory based table as you it is not crucial data. Memory based will be faster, but any time mysql is restarted it will be cleared. You'll find most software use memory based for their sessions so you would not be alone in doing this.
     
    InFloW, Jun 3, 2008 IP
  10. nebhotep

    nebhotep Active Member

    Messages:
    244
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    80
    #10
    thanks for the yip :cool:
     
    nebhotep, Jun 3, 2008 IP