To find out who is logged in ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • pipesportugal
    Second Lieutenant

    • Jul 2007
    • 130

    To find out who is logged in ?

    Hello dear colleagues,

    Is there a way using a PHP expression to find out who is logged into my website reserved area ?

    I have a field on the database that is set to 0 or 1 depending if the user is looged in or not, but after a while he gets logged out, because of inactive time reason and this field is not geting updated.

    Also if he closes the browser without hiting the logout button, I also get the info that they are logged in when on reality they're not.

    Is there a way to fix my problem ?

    Thanks in advance for all the suggestions,
    pipesportugal
  • navaldesign
    General & Forum Moderator

    • Oct 2005
    • 12080

    #2
    Re: To find out who is logged in ?

    You should also have a "time" field for each user that needs to be automatically updated with each "hit" (page opening) the user performs. After the set time period (usually 15 minutes) from the last "hit" the script cosiders the user logged off and updates the "logged in" flag field.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

    Comment

    • pipesportugal
      Second Lieutenant

      • Jul 2007
      • 130

      #3
      Re: To find out who is logged in ?

      Hi,

      What about with the "sessions", "cookies", "setcookies" and globals and all that "strange" php stuff ? no way ?

      pipesportugal

      Comment

      • navaldesign
        General & Forum Moderator

        • Oct 2005
        • 12080

        #4
        Re: To find out who is logged in ?

        It DOES use sessions. You see, when a user visits the site, a authorisation session is installed (usually session[username] and session[password]. Or anything similar. With each "hit" (page opening) the autorisation code checks to see if the user is autorised. If the session is valid, it allows the user to view the page. At this point, as happens with this forum where you can see who is logged in, the script updates the users profile record in the database with (usually) the time and the URL he is viewing. Also, usually, there is a Last visit field in the database, that allows the script to keep track of that too.

        From this point on, a simple query to the database, can, at any moment, show you who is logged in, by looking into the database to see for the last hit time field having a value that is greater than the (current time - session duration). The query will return the details of all users that have performed a hit in the last 10 - 15 minutes (depending, as i said, on the session duration set by the administrator of the script)
        The only actual limitation is that no one will actually log out when leaving the site, so, for those 10 or 15 minutes that the session remains open, the script will still consider the user logged in.
        Navaldesign
        Logger Lite: Low Cost, Customizable, multifeatured Login script
        Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
        DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
        Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

        Comment

        • Watdaflip
          Major General

          • Sep 2005
          • 2116

          #5
          Re: To find out who is logged in ?

          You would need to implement a time field as naval has suggested, but you can just have a cron job check every so often and if the current time + how long the user can be logged in for is greater then the last recorded activity for that user to log them out.

          Register/Login Script
          Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

          Comment

          • pipesportugal
            Second Lieutenant

            • Jul 2007
            • 130

            #6
            Re: To find out who is logged in ?

            Cool my friends !
            Those suggestions were great !

            I guess You guys must be already tired of "listening" to this same stuff all the time, but I'll say it anyway:
            - You people are the best !!!!

            pipesportugal

            Comment

            Working...
            X