Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: users online

  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    This little Earth.
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts

    users online

    i'm able to code to track users' movements throughout the site, a bunch of login details, etc. but if i want to have a "Users online" feature, i'll need to know when users logs off. i'll have a 'logoff' form of course, which will update the 'user' table in the database to 'not logged in', but lots of people don't bother to sign off. they just close the browser window or disconnect. how can i track when they've done this?

    i'm using sessions mainly.
    how can i track when a user has stopped being logged in?
    'If you don't stand for something, you'll fall for anything.'

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    United Kingdom Confused: Often
    Posts
    859
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmm... well from the sounds of what you describe... you're using sessions to see where everybody is, ay?... so i'll presume "logging out" ends the session, eh?... now... when you close the browser window that also ends the session, so either way, the session's been ended...

    im no php guru though so i could be wrong ...
    redhead

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    This little Earth.
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    lol i know the session'll be ended in any case..
    the problem is how do i know when?
    like if i close this Coding Forums window which i'm viewing right now, my session will end, then if anyone refreshes the CF home page, they won't see me in the list of current users online. how did the database get to know that I'm not online any more?
    'If you don't stand for something, you'll fall for anything.'

  • #4
    New to the CF scene
    Join Date
    Apr 2003
    Location
    Earth
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There is a way to do it because my php teacher has done it on his site.

    http://www.nrnr.net/

    I have thought about how it could be done many times but have not asked him much about it but one of the other co-webmasters of the site said that the whois online code can not be made accurate to the second and has to made to an resonable time limit. In the url above, it's reset to 5 minutes per page click.

    Now when he said that, the first thing that came to mind was ofc a cookie. I think if you set a page hit field in the database to generate a cookie that lasted for 5 minutes to be used in a whois online table, it should work. I've yet to have the nerve to toy with a code of my own to test it's possibilities but I would think that is your best bet.

  • #5
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you were to set it at say 15 minute intervals, of checking who is online. When a user visits a page, have it put a value in a database of time()+900, then when someone visits the page, get them to check the time.

    If it is greater than the value entered, delete the value, else leave it there.

  • #6
    New Coder
    Join Date
    Nov 2002
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    on my sites i like to put 2 values on ever user record (in a database table).
    last page = url of the last page they were at
    last page date time = timestamp of when they clicked that page.

    then for a 'who's online' section just do a lookup in your users table and limit to those users who have a
    last page date time greater than whatever your session time out is.

    You can also use this to show admins where folks that are logged in are.

    Nice thing about this is you can make custom pages that sort users by last page hit day/time. to see who your active users are.


  •  

    Posting Permissions

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