By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,216 Members | 1,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,216 IT Pros & Developers. It's quick & easy.

PHP Chat

The1corrupted
100+
P: 134
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...
Feb 22 '07 #1
Share this Question
Share on Google+
3 Replies


Motoma
Expert 2.5K+
P: 3,235
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.
Feb 23 '07 #2

The1corrupted
100+
P: 134
Last touched time? Could you explain with a code example?
Feb 23 '07 #3

Motoma
Expert 2.5K+
P: 3,235
Last touched time? Could you explain with a code example?
[PHP]
$db->query("DELETE FROM timeTable WHERE userId =".$_SESSION['userId']." OR sessionId = '".session_id()."'");
$db->query("INSERT INTO timeTable (userId, sessionId, lastTouched) VALUES (".$_SESSION['userId'].",'".session_id()."', '".date('Y-m-d h:i:s')."')";
[/PHP]
Feb 23 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.