Question

I am wondering, if there is a real-time way time ping a user and see if that user is still only.

My site uses jQuery, PHP and CRON jobs so I was wondering what would be the best way to check that the user is still online.

Each user is issues a cookie aka session key but I don't want to just go by that.

I know real-time analytics are able to it, using javascript so I wonder if I could also do the same thing.

Thanks

Was it helpful?

Solution

Any method you choose will work the same as what you mentioned, it will just update more often.

You can use an ajax call that pings the server every x seconds and as soon as that stops you'll know they left at most x seconds ago.

A similar option is to use WebSockets or Flash to hold a socket connection with the server and mark them as logged off the moment that socket connection is broken.

Both these options are a bit more difficult to scale than sessions and cookies.

OTHER TIPS

it could be done via continues ajax call from client but not recommended.

I suggest use flash or something like that to reduce number of ajax request to the server.

Question is very confused and ambiguous.

No you can't 'ping' a user. You can ping an IP adderss - but the IP addresses you see at your server probably don't map on a one-to-one basis with users.

Which user? All users? Why? What will you do with the information? Have you got a better reason than "I don't want to" for not using session data?

"I know real-time analytics are able to" - then you must know the method they use to do this - or are you just buying the sales speak?

I guess only way to get "real-time" data is to use web-sockets.

another way which is less acurate ( with delay ) is to use repited ajax calls. say 1 per 60 seconds.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top