+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: frustrating problem with php and javascript

  1. #1
    playminigames is offline x10 Sophmore playminigames is an unknown quantity at this point
    Join Date
    Jul 2009
    Location
    earth
    Posts
    216

    frustrating problem with php and javascript

    Ok so on my site you can see friends that are online, so why you log out they go offline, but when you close out the browser they log out, but they dont go "Offline". so i tried a little ajax with it for unload to send a request to the page to logout, but it logs out every time you change the page, so it doesnt work. Any help with this would be great.

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: frustrating problem with php and javascript

    One option would be to keep a count of open pages on the server. Add onload and onunload handlers that request pages to increment and decrement the count. When the count is 0 for 1 minute or more, the user's status is "offline" but is still considered logged in.

    Another option is to have pages make keepalive requests every minute or so. These requests can set other status information, such as "away" when the user hasn't interacted with the page for more than a given amount of time. If a user is logged in but a keepalive request hasn't come in for a given period, change the user's status to "offline".

    Note that the former will be tricky to implement properly and the latter is inefficient.
    Last edited by misson; 11-02-2009 at 10:38 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    playminigames is offline x10 Sophmore playminigames is an unknown quantity at this point
    Join Date
    Jul 2009
    Location
    earth
    Posts
    216

    Re: frustrating problem with php and javascript

    thanks, i was thinking about the second option, but i wasnt quite sure, thanks for the input!

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: frustrating problem with php and javascript

    What does knowing that a friend is online get someone? What can they do with that knowledge? Can they interact with the friend in any way?
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    playminigames is offline x10 Sophmore playminigames is an unknown quantity at this point
    Join Date
    Jul 2009
    Location
    earth
    Posts
    216

    Re: frustrating problem with php and javascript

    im hoping to make a chat system, but that will be way later, as im not that good at javascript yet

  6. #6
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: frustrating problem with php and javascript

    One thing to look into is Comet. You could layer a chat app onto it and it can provide a way of telling whether someone is online or offline, though the different Comet techniques have their own impact on resource usage.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  7. #7
    playminigames is offline x10 Sophmore playminigames is an unknown quantity at this point
    Join Date
    Jul 2009
    Location
    earth
    Posts
    216

    Re: frustrating problem with php and javascript

    yes, i thats what i was thinking, but it doesnt need to be done now. Thanks for all the help

  8. #8
    crisbacera is offline x10Hosting Member crisbacera is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    2

    Re: frustrating problem with php and javascript

    Quote Originally Posted by playminigames View Post
    yes, i thats what i was thinking, but it doesnt need to be done now. Thanks for all the help

    just replying only... :D

  9. #9
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: frustrating problem with php and javascript

    Quote Originally Posted by crisbacera View Post
    just replying only... :D
    Why? You're not adding anything to the discussion. Take a closer look at the terms of service: you don't need to post fortnightly, just log on to the forum.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  10. #10
    garikr's Avatar
    garikr is offline x10Hosting Member garikr is an unknown quantity at this point
    Join Date
    Aug 2009
    Posts
    46

    Re: frustrating problem with php and javascript

    This is a bit off topic, just letting you know... this is what I get when I tried to register on your site(www.playminigames.co.cc)

    Warning: Missing argument 4 for MySQLDB::addNewUser(), called in /home/pmg/public_html/include/session.php on line 645 and defined in /home/pmg/public_html/database.php on line 158

    Warning: Missing argument 5 for MySQLDB::addNewUser(), called in /home/pmg/public_html/include/session.php on line 645 and defined in /home/pmg/public_html/database.php on line 158

    Warning: Cannot modify header information - headers already sent by (output started at /home/pmg/public_html/database.php:15 in /home/pmg/public_html/process.php on line 213

    Hope this will help with your testing

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. PHP memory limit problem when creating zip file on fly?
    By DaveBC in forum Programming Help
    Replies: 8
    Last Post: 09-04-2008, 05:06 PM
  2. Send multiline PHP variable to javascript
    By last2kn0 in forum Programming Help
    Replies: 3
    Last Post: 07-07-2008, 04:33 PM
  3. include php within javascript
    By thezone1 in forum Programming Help
    Replies: 5
    Last Post: 04-24-2008, 12:50 PM
  4. Recursive PHP array to Javascript array/object
    By Veridis in forum Programming Help
    Replies: 0
    Last Post: 04-16-2008, 02:55 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers