Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Robert Walker
Robert Walker
16,514 Points

Using Node.js on a website built using PHP to get current online users

I have been learning about Node here on Treehouse but have fiddled around with it building a chat sometime ago using express and socket io and it all seems easy enough but with watching the course here on Treehouse I was thinking about a project im currently building in PHP and a current issue with how best to get current online users.

It got me thinking can I not use Node for this in some way?

In PHP I would need to either count sessions which is bad because if someone closes the browsers the session still shows for a while or I can store activity time every page hit and then check if activity time is less than 5 minutes ago but it all requires a lot of calls and checks and in the end is not always going to be that accurate.

So with node being able to have a persistent connection it seems ideal to check my online user status, problem is im not really sure how this would work, what I would require in terms of server and so on.

Does anyone know how I might go about this?