SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    want to log users login and logout time ?

    i 've a loing interface, user enter its id and password and gets login, in the mean while the login timestamp is taken , and also the logout if the user logged out, but if the user closes the browser (window) or the system gets restarted then the logout time cannot be noted, is there any way that i can stroe logoff time properly ?????


    Help PLZ ASAP. ????????
    [COLOR=SlateGray]
    Web Developer @ VeriQual

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    No, you'll not be able to accurately record the log off time of visitors. You can only guess. Keep another timestamp in the table which is updated on every page view, and when that timestamp is over 30 minutes old (or whatever threshold you want), you can guess that the user has left without logging out.

  3. #3
    SitePoint Member
    Join Date
    May 2006
    Location
    Southampton UK
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can use the apache logs for when the user closes the browser window, and pull this information into your script. That said you will need a host that allows you to this.

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AlphOmega View Post
    you can use the apache logs for when the user closes the browser window, and pull this information into your script. That said you will need a host that allows you to this.
    Closing a browser window doesn't generate an HTTP request...

  5. #5
    SitePoint Member
    Join Date
    May 2006
    Location
    Southampton UK
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had no idea what was in my head when i wrote that

  6. #6
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    may b a bad idea .... try a counter which checks every after some inteval for active user and inactive users....

  7. #7
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    u r using apache or IIS ?

  8. #8
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  9. #9
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    like dan said, your first and only reliable method of determining when they logged out is by keeping track of inactivity time.

    the accuracy can be improved sometimes. for example:

    if the user clicks the logout button/link, then you use that instead of inactivity.

    you could improve the accuracy of the inactivity method by forcing the user to continually recontact your webserver. some ways to do this:
    -use a small hidden iframe pointed to an update_activity.php script which refreshes every minute or so.
    -or use javascript to request the update_activity.php script on your server every minute or so.

    that script would then update thier last activity each time its loaded.
    drawback to that is, a user who leaves thier browser open and walks away from thier computer will now be conisdered active until thier computer goes to sleep. i personally leave my browser open quite often. not all browsers will obey your javascript or iframes or refreshes either, although most will and i think thats probably acceptable to you.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •