How to get informed Clients Disconnected from the Server

Discussion in 'PHP' started by llcoollasa, Jan 19, 2010.

  1. #1
    How to get informed Clients Disconnected from the Server

    HI everyone?
    1. is there a way to determine how many clients(web browsers) connected to the server??

    2. is there a way how to send a message to the client from the server. Not client to server...

    Example:
    Assume there is a web site that showing online score of a game.

    How was it done?

    is there a client script(js) that request score from the sever or server send score to the client.

    i like to learn.....
     
    llcoollasa, Jan 19, 2010 IP
  2. dsignresponder

    dsignresponder Greenhorn

    Messages:
    81
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    18
    #2
    HI llcoollasa,

    1. - absolutely YES! Generally, PHP sessions are used to handle and track visitors to a website (server), registered members or guests both can be tracked and determined how many of them are looking at the site, where are they from (IP address), which pages are they looking at, etc.
    You should learn about session handlers at Zend or/and PHP.net , however best thing is to use complete developed frameworks for that purpose (they are maintained, updated and tested packages)

    2. - JavaScript (unlike to PHP which is server side) is a client side script which is used (among much more...) to display immediate changes at the browser (no need to reload the page) according to the visitor's action (OnClick, OnChange, OnFocus, etc.)
    Learn JavaScript from start or/and with tutorials!

    Regards
    :D
     
    dsignresponder, Jan 20, 2010 IP
  3. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sessions won't tell you who is "connected" to the site now. They will let you find out who connected within the last half hour or however long your session lifetime is set to. Someone can look at a page, close their browser, shut down their computer, put it in their car, drive 20 minutes across town to the city landfill, and throw the computer in the crusher, and your web server will still have an open session for them.

    If you need to know in real time who is connected then you need to use Javascript on the client side to keep the server apprised.
     
    SmallPotatoes, Jan 20, 2010 IP
  4. dsignresponder

    dsignresponder Greenhorn

    Messages:
    81
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    18
    #4
    I agree with you (generally) however if you read carefully, you'll see I didn't say sessions can tell us who is "connected" to the site now! I said sessions can be used to handle and track visitors, but I don't want to make duplicate posts! ;)
     
    dsignresponder, Jan 20, 2010 IP