User Session Handling, Server Session (need Some Advice!)

Discussion in 'PHP' started by bartolay13, Nov 2, 2007.

  1. #1
    hello there,

    i need some advice on how to secure and see who's online, I have created a GUI for an administrator, and I want to install this feature, to see who's online on the index page...

    the method that i am thinking is when a user is successfuly logged in, then an alteration to the mysql db will be made,
    for example:

    $_SESSION['user21'] != ""
    /* if logged in */
    then:
    status = Online
    /* this will be the changes in the field (status) and the user status(Online) in the mysql db */

    i need some advice on this one, and some advices on security...

    Thank you In advance...
    bartolay13
     
    bartolay13, Nov 2, 2007 IP
  2. tonybogs

    tonybogs Peon

    Messages:
    462
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    - When a visitor comes to your website and you create a session log that into the database along with the time created/modified
    - Assuming your session has a time out , lets say 15 minutes.
    - Each time a user touches a page update the time modified to the current time.
    - Then to find the users on line you can select from all sessions where the modified time is within 15 minutes.

    Of course if your site is high traffic you dont want to write to the db for every page load so you can use something like memcached to keep track of the sessions activity for you.

    Hope this helps
     
    tonybogs, Nov 3, 2007 IP
  3. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #3
    thanks,

    i created a session log table for the users login and logout.
    addition to that, what do you mean by memcached?
     
    bartolay13, Nov 3, 2007 IP