Online Status from Authentication Plugin

I am using the CakePHP Authentication Plugin.


Is any way to use this Plugin to show your online/login status also to others?


Not directly, no. What “online” means is highly subjective. If I log in to your site and then close my browser, the site doesn’t know I’m gone. How long do you wait before you decide I’m not “online” any more? It’s possible to add things like a heartbeat Ajax call to improve on this. But all of it basically comes down to you needing to keep a record somewhere of the last time you “saw” a particular user, and use that to indicate who is online.

hey i think a ajax heartbeat will produce too much traffic. If someone leaves the website and he will still be online for 5-10minutes it will be no problem for me…

Yeah, that’s the tradeoff for precision.

Like I said, I don’t think this is anything that the auth*n plugins do for you. You’ll presumably need to add a field to your users table with last visit time, update that somewhere reliable (the beforeFilter callback, perhaps?), and then you can reference that wherever you need to.

If you want to go fancy you could look into websockets. If haven’t personally looked into if this is possible, but its something I’d investigate if had a need.

For such a simple thing websockets is an overkill, I’d suggest long-poll AJAX. That would be least amount of work and easier to test in my opinion.