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
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.