Who's signed in

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • szar

    Who's signed in

    Anyone know a good way to check if someone is signed in, has a session
    going, etc.? I could have a signed in field that updates from 'yes' to 'no'
    when they sign out, but that wouldn't work well when the session times out
    or they just close the browser. Thx.
    Steve.


  • szar

    #2
    Re: Who's signed in


    "szar" <none@nowhere.n et> wrote in message
    news:DiKlb.486$ Wf2.339@newssvr 22.news.prodigy .com...[color=blue]
    > Anyone know a good way to check if someone is signed in, has a session
    > going, etc.? I could have a signed in field that updates from 'yes' to[/color]
    'no'[color=blue]
    > when they sign out, but that wouldn't work well when the session times out
    > or they just close the browser. Thx.
    > Steve.
    >
    >[/color]

    BTW, I do have access to cron jobs but nothing else on the server.
    Steve.


    Comment

    • Erwin Moller

      #3
      Re: Who's signed in

      szar wrote:
      [color=blue]
      >
      > "szar" <none@nowhere.n et> wrote in message
      > news:DiKlb.486$ Wf2.339@newssvr 22.news.prodigy .com...[color=green]
      >> Anyone know a good way to check if someone is signed in, has a session
      >> going, etc.? I could have a signed in field that updates from 'yes' to[/color]
      > 'no'[color=green]
      >> when they sign out, but that wouldn't work well when the session times
      >> out or they just close the browser. Thx.
      >> Steve.
      >>
      >>[/color]
      >
      > BTW, I do have access to cron jobs but nothing else on the server.
      > Steve.[/color]

      Hi Steve,

      Two solutions,

      1) using the filesystemstora ge and session.gc_prob ability
      (I don't recommend this)

      If you work with sessionstorage on the filesystem (session.save_h andler =
      files), you could try this:
      (It is a bit ugly)
      When you create your session, store the name of the sessionfile (often
      stored in temp-directory, check your php.ini session.save_pa th = /tmp) in
      some databasetable accompanied with the username.
      Check every X minutes the if the filenames stored in the database are still
      in the tempdirectory.
      If not delete them from your table.

      To make this a little more reliable you might consider to change the value
      of session.gc_prob ability to a much higher value (100), but this means of
      course your garbagecollecti on of stale sessionfiles will run every times.

      from php.ini
      ; Percentual probability that the 'garbage collection' process is started
      ; on every session initialization.
      session.gc_prob ability = 1

      2) Build it yourself
      Maybe a better approach would be to:
      a) store in a db-table the phpsessid with a username and a timestamp.
      b) every time you do something in the session, update the timestamp in the
      db for this user.
      c) when you need the 'online visitors', just delete old records from the
      table, and what is left are possible online users.

      I think the second approach is better.

      Good luck,
      Regards,

      Erwin Moller

      PS: In Java we have this beautifull HttpSessionBind ingListener, but I am not
      aware of similar functionality in PHP.

      Comment

      • Ralph Freshour

        #4
        Re: Who's signed in

        I use a session variable to hold the users login name - if that var
        isn't == "" then someone has signed in - to see who, I just read the
        session var.

        To determine if they are still online I use a MySQL table called
        online and on every web page I make a call to update that table with a
        timestamp - each user has a record in the online table so I can tell
        who is online based on the timestamp - I use 10 minutes - if the
        timestamp is within 10 minutes of now() then I assume they are still
        online.



        On Thu, 23 Oct 2003 06:11:47 GMT, "szar" <none@nowhere.n et> wrote:
        [color=blue]
        >Anyone know a good way to check if someone is signed in, has a session
        >going, etc.? I could have a signed in field that updates from 'yes' to 'no'
        >when they sign out, but that wouldn't work well when the session times out
        >or they just close the browser. Thx.
        >Steve.
        >[/color]

        Comment

        Working...