Page 1 of 1

one user information is showing in one computer only

Posted: Sun Oct 30, 2005 12:40 pm
by rajan
i want to restrict users to see particular user information according to username when other computer is showing that information.

Posted: Sun Oct 30, 2005 1:35 pm
by Ambush Commander
If I read you correctly, you want to implement a "read lock"?

Posted: Sun Oct 30, 2005 1:45 pm
by s.dot
If I understand correctly, if a user is logged in, you don't want someone else to be able to log in with that username on another machine.

Most likely you will need a timestamp field in a database that is updated with each action the user does. Determine a time online as like within the last 5 minutes or so.

Whenever someone tries to login, check to see if that timestamp is within the last 5 minutes. If it is, restrict access from that user.

Posted: Sun Oct 30, 2005 2:31 pm
by rajan
what about when he does not do anything in that page for 5 minute then whole idea is failed and what about if does not use logout to clear timestamp.

Posted: Sun Oct 30, 2005 2:35 pm
by Ambush Commander
That's the problem with Pessimistic Locking. It's a thorny issue, and most of the compromises are between effectiveness, and usability.

It has been suggested to use JavaScript and make the user "phone in" to the site every minute so that he doesn't expire as long as the page is on.

Posted: Sun Oct 30, 2005 3:43 pm
by s.dot
this would be better handled by a client side language, as mentioned above. You could execute a javascript function in a hidden iframe or something similar, to update the timestamp on an interval. Then there's the issue of server problems, and the page getting stalled and not loading.

Posted: Sun Oct 30, 2005 3:46 pm
by Chris Corbyn
*cough*

AJAX

Posted: Sun Oct 30, 2005 6:42 pm
by rajan
i want realtime solution can not not bear the single seconds for other user to allow.

Posted: Sun Oct 30, 2005 6:44 pm
by Chris Corbyn
rajan wrote:i want realtime solution can not not bear the single seconds for other user to allow.
AJAX will be as close as you'll get if you want to use PHP.