Skip to Content Skip to Menu

User Status: ONLINE as long as Browser Open

12 years 9 months ago #186597 by fabiankarsch
User Status: ONLINE as long as Browser Open was created by fabiankarsch
Hi Forum,

I need a solution for my community to show live userstatus. Means: As long as User is on webpage or has the webpage in an Tab or Window oppened, the USerstatus is ONLINE. (Green signal showing in Field: Online Status)

But when user closes the tab, he should automatically be logged off... -> RED Signal in Field: Online Status.

Anybody some ideas? Thank you very much

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48437
  • Thanks: 8275
  • Karma: 1443
12 years 9 months ago #186643 by krileon
As far as I am aware you can't do that. A website can't check to see if a users browser is open or not. There are some JS based solutions that can determine when a browser closes and such, but JS is local and not server side so it would need some form of Ajax to communicate constantly with your site (slamming it with GET requests non-stop). It's just not a viable solution. You can check for a session however, which is what CB already does with the online status field.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • sfraise
  • sfraise
  • OFFLINE
  • Posts: 96
  • Thanks: 14
  • Karma: 4
12 years 9 months ago - 12 years 9 months ago #186693 by sfraise
Ajax is the only solution I think here like Krileon said, I'm looking for a similar solution based on last activity (page load) which is a bit easier than what you're wanting.

What you could do that wouldn't be so resource intensive is create a column in your comprofiler table (or session table maybe) and use a bit of ajax to update that column with the current time every minute or five minutes or whatever. Then use your own online code that checks that value every so many minutes, subtracts that time from the current time and if that value is > so many minutes than that member is considered offline. However you could run into issues with them showing as online after the Joomla session has expired and logged them out. It all depends on what all you need to be able to do.

There's probably a much better solution than what I just gave but maybe it can start you on the right path.
Last edit: 12 years 9 months ago by sfraise.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48437
  • Thanks: 8275
  • Karma: 1443
12 years 9 months ago - 12 years 9 months ago #186710 by krileon
That might work, but again you're slamming your site. Say you have 1,000 users and you perform the check at an interval of 5 minutes. That's 12,000 page hits in 1 hour. So just a userbase of 1,000 is having the footprint of 12,000 which is not good. This would result in extremely slow browsing and probably crash the server after awhile as you'll probably hit CPU limitations unless on shared host.

I suggest just increasing the session lifetime in Joomla global configuration to something like 999 or 9999 minutes. This means they'll have to log out or reach 9999 minutes before their session expires and are shown as offline. Maybe that's a bit too high though and perhaps 2-3 hours should be sufficient.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 12 years 9 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • sfraise
  • sfraise
  • OFFLINE
  • Posts: 96
  • Thanks: 14
  • Karma: 4
12 years 9 months ago #186716 by sfraise
Absolutely for a high traffic site my suggestion will drive your cpu load through the roof as it will be slamming mysql way too much.

Please Log in or Create an account to join the conversation.

12 years 9 months ago - 12 years 9 months ago #186730 by fabiankarsch
Replied by fabiankarsch on topic Re: User Status: ONLINE as long as Browser Open
Thank you for the discussion.
we are trying some kind of Pop-Up Notification, when user wants to close Browser -> then gets reminder that he has to logg out.

But sadly, I fear, that even when whole browser is closed by user, the window does not appear...
Last edit: 12 years 9 months ago by fabiankarsch.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum