tags:

views:

58

answers:

2

how can i alert the user already logged in for the new user logged in........suppose....

user1 one is currently logged in and user2 is offline. i want to alert user1

when user2 logged in............

how can i achieve this

+3  A: 

Well, it requires a lot of code so it's unlikely someone will answer with a copy&paste solution.

Anyway, I'll point you in the right direction: You could use Reverse AJAX; for example have the clients periodically request a page on the server via javascript, or have them request a page that "never returns" until someone else logs in with the same account.

Andreas Bonini
A: 

If you're looking for logic:

I would keep a table of Currently Logged In Users and a table of Notification Relationships

You could write a simple PHP script that checked to see if any row in the Notification Relationships table are both in the Currently Logged In Users table.

You could use a setTimeout() event to run a jQuery ajax script every 20/30 seconds or so, that would hit your php script.

If you're looking for actual code, I could probably get a demo working in an hour or two.

Zack