concurrent logins

11 years 2 months ago #218635 by jennjoom
concurrent logins was created by jennjoom
Is it possible to restrict a user to a specified amount of concurrent logins? We provide subscriptions for educational facilities and would like to specify user accounts at:
1 login (no concurrent logins)
3 concurrent logins
500 concurrent logins

Please Log in to join the conversation.

11 years 2 months ago #218649 by krileon
Replied by krileon on topic Re: concurrent logins
You can try the below. I've no idea how well it'll work with CB, but it might do the trick.

extensions.joomla.org/extensions/access-a-security/site-security/login-protection/15932

If not you can try searching for other similar extensions or develop one. It's also possible with CB Auto Actions, but still would require coding in a Code action to check IP address and sessions.


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.

11 years 2 months ago #218663 by jennjoom
Replied by jennjoom on topic Re: concurrent logins
Thanks! We've tried plugins such as the one you referred to, but they're limited in that they allow one login, or unlimited. Others don't work well with CB or check by IP address instead of user name.
I was really hoping CB subs could handle it, but hopefully I'll be able to find a developer to write a plugin for us.

Please Log in to join the conversation.

11 years 2 months ago - 11 years 2 months ago #218665 by krileon
Replied by krileon on topic Re: concurrent logins
Best approach is a plugin that checks the session database for an existing session. If an active session already exists, delete it, and continue with login. This would logout the previous user. This is the least intrusive to the user themselves (so they don't get stuck waiting for a session to expire) and avoids issues with closing browser without logging out first (which would cause them to wait for session to expire).

This approach is actually extremely simple and could be done with a simple Query action with CB Auto Actions with the after login trigger. It'd take no programming beyond writing the query, which would be as follows.
DELETE FROM `#__session` WHERE `id` != ( SELECT `id` FROM `#__session` WHERE `userid` = '[user_id]' AND `client` = 0 ORDER BY `time` DESC LIMIT 1 ) AND `userid` = '[user_id]' AND `client` = 0

To explain the query it basically queries the database to delete all sessions except for the newest. This ensures only 1 session can exist at a time. If there is no session Joomla will log them out on next page load so this gives you the 1 login at a time only. It is also note prone to silly username or IP address checking issues.

If you want to allow multiple logins you'd just modify the query as follows to ignore the 3 latest.
DELETE FROM `#__session` WHERE `id` NOT IN ( SELECT `id` FROM `#__session` WHERE `userid` = '[user_id]' AND `client` = 0 ORDER BY `time` DESC LIMIT 3 ) AND `userid` = '[user_id]' AND `client` = 0


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