users listed as online after session should have timed out

3 years 10 months ago #318570 by joomally
The list of user's displayed by the CB Who's Online module includes users whose sessions should have timed out.

To test it, I registered with a new user, which then 'auto-logged in'. I then closed the browser without logging out. I then waited 8 hours (because the session lifetime is set to 6 hours). Even after this time, the CB 'Who's online' module is still showing the user as being online. The users profile shows the user as 'Last Online' - 'about 8 hours ago'

In Global configurations, I have
Session Handler: Database
Session Lifetime: 360

also:
Cache Handler: File
Cache Time: 15
System Cache: OFF-Caching disabled

In Joomla plugins, the only plugins I find when I do a search for 'CB' are 'Captcha - CB AntiSpam','System - CB Auto Actions', 'cbpaidsubsbot'. All of them are enabled.
In Joomla plugins, the only plugin I find when I do a search for 'cache' is 'System - Page Cache' and this is disabled.

I went to 'System'->'Clear Cache' and clicked on 'Delete all'.
I also went to 'System'->'Clear Expired Cache' and clicked on 'Clear Expired Cache'

Still the user is shown as online.

Is there anything else that I need to do ?

Thanks

Please Log in to join the conversation.

3 years 10 months ago #318575 by krileon
What mode exactly are you using in your CB Online Module? We're just directly querying _session database table the same way Joomla does it to retrieve online sessions. If that session has a user id in the "userid" column and the "guest" column is set to 0 they are considered as online by Joomla and also by our module. Logging out should set "guest" to 1 and set "userid" to 0. A session expiring will soon clear from the database, but it doesn't clear immediately so that's the issue you maybe seeing is where they're expired but Joomla hasn't cleared the expired session from database yet.

Even after this time, the CB 'Who's online' module is still showing the user as being online. The users profile shows the user as 'Last Online' - 'about 8 hours ago'

The last online field just notes when they logged in via the lastvisitdate. It does not take into account the session lifetime. The online status field will show if they're actually online or not by checking their session.


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 to join the conversation.

3 years 10 months ago #318598 by joomally
Thanks for your reply.

I think you're right that the issue that I'm seeing is because the session expiring doesn't clear immediately from the database. Sometimes it takes 16 hours to clear ! This is not very helpful for us, and is not a CB issue.

I would like to instead create a CB list that displays anybody who has used the site in the last 4 hours - even if they have logged out. I think this can be done using a filter on the 'Last Online' field. I'm just not sure what to set the filter to. I tried many options for 'lastVisitDate' and 'less than' but couldn't find one that works.

Is it possible to create a list that shows anyone who has used the site in the last 4 hours ?

Thanks

Please Log in to join the conversation.

3 years 10 months ago #318613 by krileon
You'll need to use an Advanced Filter to compare dates. Example as follows.

u.`lastvisitDate` >= DATE_SUB( NOW(), INTERVAL 4 HOURS )

The above compares the last visit date in the _users database table against the current time minus 4 hours. So anyone who has logged in within the last 4 hours should be visible in the list. The database tables use the following aliases as well, which is useful if you need to use an advanced filter against one of their columns.

_comprofiler = ue
_users = u
_user_usergroup_map = g


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 to join the conversation.

3 years 10 months ago #318628 by joomally
Thanks.
Is the time taken from when they last logged in or when they last clicked on something ?
I would like 4 hours from the last time they clicked on something (if this is available). So if they logged in 5 hours ago, but were using the site for a couple of hours then they would be included.
Thank you

Please Log in to join the conversation.

3 years 10 months ago #318637 by krileon
lastvisitDate is only set when they login. A field that updates anytime they click something or do something on your site doesn't exist.

I would like 4 hours from the last time they clicked on something (if this is available). So if they logged in 5 hours ago, but were using the site for a couple of hours then they would be included.

Then you'll probably also need to check if that're logged in via subquery to the sessions database table in addition to the lastvisitDate check. The below Advanced Filter causes the userlist to show only users that are online.

( SELECT COUNT(*) FROM `#__session` AS s WHERE s.`userid` = u.`id` AND s.`guest` = 0 ) > 0

This can then be combined with your lastvisitDate check as shown below.

( u.`lastvisitDate` >= DATE_SUB( NOW(), INTERVAL 4 HOURS ) ) OR ( ( SELECT COUNT(*) FROM `#__session` AS s WHERE s.`userid` = u.`id` AND s.`guest` = 0 ) > 0 )

The user would either need to have logged in within the last 4 hours or have active session in the database.


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 to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.311 seconds

Facebook Twitter LinkedIn