Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 26

Thread: Logout help

  1. #11
    Join Date
    Feb 2006
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, so I've read through your script a couple times, i understand the majority of it. I understand that one line now too. But i'm left with one last question: that part where it checks their last seen agaisnt date_sub(now and interval), but does that mean that the page has to be refreshed every 5 seconds or something? As in the Users Online box would be an iframe where a meta tag refreshes it every several seconds?

  2. #12
    Join Date
    Feb 2006
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    One more thing, i see all over your script things like "set lastseen=NOW()".
    But nowhere in the script can i find Function NOW() {. or something like that. Is NOW() a built in PHP function that returns the current time in a datetime format or something of that sort?

  3. #13
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    that part where it checks their last seen agaisnt date_sub(now and interval), but does that mean that the page has to be refreshed every 5 seconds or something? As in the Users Online box would be an iframe where a meta tag refreshes it every several seconds?
    No, the message-display box is a frame that refreshes every few seconds, primarily by AJAX but falling back onto meta refreshes if AJAX isn't supported.
    One more thing, i see all over your script things like "set lastseen=NOW()".
    But nowhere in the script can i find Function NOW() {. or something like that. Is NOW() a built in PHP function that returns the current time in a datetime format or something of that sort?
    Close, but it's a MySQL function.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #14
    Join Date
    Feb 2006
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ohh thats why its always in the queries. Hehe, i should've been able to pick that out.

    So if the message box is the one that refreshes, how does the Online Users part check everyones lastseen time? Is that the AJAX part?

  5. #15
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    So if the message box is the one that refreshes, how does the Online Users part check everyones lastseen time? Is that the AJAX part?
    It doesn't. Users viewing the Online Users page aren't considered to be online.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #16
    Join Date
    Feb 2006
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ohh Ok. So let me just run this over one last time, the user logs in, and then their lastseen variable is set, everytime they send a message, AJAX causes that message page to refresh, thus updating their lastseen time? And thats how that goes?

    hehe, sorry for my ignorance. I'm very new to php.

  7. #17
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    everytime they send a message, AJAX causes that message page to refresh, thus updating their lastseen time?
    Not every time they send a message but every time the message box refreshes. If they leave the page the message box stops refreshing, and after the interval they're considered to be logged out (which actually takes place when another user next views the page, although the timestamp is the user's last-seen time).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #18
    Join Date
    Feb 2006
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Aha, so i was pretty much right. That's pretty good for just starting PHP.

    Allright one last question, which is pretty easy: INTERVAL 30 SECONDS - could i do something like INTERVAL 500 SECONDS?

  9. #19
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    could i do something like INTERVAL 500 SECONDS?
    Of course. It would have to be substantially more that the refresh period, though.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #20
    Join Date
    Feb 2006
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, so i understand how to do this whole thing in a chatroom now, but i have yet another problem.

    Say i want to use this in my website, where on every page ther is a little box that says Members Online: 485. (Or something) How would i apply this time based method to each page? Im assuming i would add to every page a function that updates the users LASTSEEN to "NOW()". But then how would i fit in the function that checks their lastseen against the time now? For example the page loads, their lastseen is updated, but if i use the function to check their lastseen there too it will allways check out to be that the user has been seen within the past 30(or so) seconds.

    Basically waht i'm asking is, how do Forums such as PHPBB find out how many users are online if they use this same method?

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
  •