PHP Chat

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • The1corrupted
    New Member
    • Feb 2007
    • 134

    #1

    PHP Chat

    I'm trying to devise a way of using sessions being active/inactive in a multi-sided game which allows you to see the active users, regardless of how many (though could maybe limit to 30...) in your specific area (comparing coordinates to match yours).

    Also, I need a way to log their chat (posting to a database of course) but then have time stamps be correlated between the user's session and the stamps that go on the database.. Basically, this would enable the user to clear their screen by resetting their time stamp to 0 or to carry on the chat posts as they move if they so choose to. (Time stamps would me in mm:ss)

    I've thought this out and think it could work great but I just don't know how to approach it code wise...
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    Originally posted by The1corrupted
    I'm trying to devise a way of using sessions being active/inactive in a multi-sided game which allows you to see the active users, regardless of how many (though could maybe limit to 30...) in your specific area (comparing coordinates to match yours).

    Also, I need a way to log their chat (posting to a database of course) but then have time stamps be correlated between the user's session and the stamps that go on the database.. Basically, this would enable the user to clear their screen by resetting their time stamp to 0 or to carry on the chat posts as they move if they so choose to. (Time stamps would me in mm:ss)

    I've thought this out and think it could work great but I just don't know how to approach it code wise...

    Put the session id, userid, and last touched time for the session in a usage table. At the beginning of every page, update the time for the session id and user.

    Comment

    • The1corrupted
      New Member
      • Feb 2007
      • 134

      #3
      Last touched time? Could you explain with a code example?

      Comment

      • Motoma
        Recognized Expert Specialist
        • Jan 2007
        • 3236

        #4
        Originally posted by The1corrupted
        Last touched time? Could you explain with a code example?
        [PHP]
        $db->query("DELET E FROM timeTable WHERE userId =".$_SESSION['userId']." OR sessionId = '".session_id() ."'");
        $db->query("INSER T INTO timeTable (userId, sessionId, lastTouched) VALUES (".$_SESSION['userId'].",'".session_i d()."', '".date('Y-m-d h:i:s')."')";
        [/PHP]

        Comment

        Working...