I'm trying to set up an automation via Rules that checks if any user has an elapsed "Last Access Time" of (e.g.) 10 minutes so that they will be logged out. [Edit: Or rather shown offline]

The two functioning rules i made are based on User has logged in / User has logged out, but for the current user: They show/hide a green online indicator for each user account.

The problem is: If an user closes the browser or tab, the online indicator field remains visible -- so they are basically indicated as being online forever until they come again to use the logout button manually. I tried using "Ejector Seat" and "Automated Logout" module, but they don't seem to trigger the same kind of logout like in User has logged out

In settings.php, i also changed the session.cookie_lifetime to 0 without any effect, other than it leading to requiring relogging -- but it is only session-based, not the "true" logout, as relied on in User has logged out.

What first came to my mind was creating a new rule to do a data comparison with each automated cron run in a 10-minute Interval -- but i believe the issue is that site:current-user:last-access is not sweeping through all users in general?

---

This is the new, non-working rule:

 

Inside the "Data comparison" condition:

 

Here i was trying to test 10 elapsed seconds as a trigger for logout, but the online indicator stays. So nothing happens.

Is this even solvable with Rules or will there be a need to create custom code or a custom module for this? 

Accepted answer

Hi theflightrs, I'm not sure how your use-case is solvable with Rules, but I have another idea. In Views, there is a filter called "User account: Last access". I'm using it for a "Who's online" block (see screenshot below). You could try to combine that filter it with other views filters or with block visibility conditions to adapt the block to your needs.

Comments

Olafski's picture

Hi theflightrs, I'm not sure how your use-case is solvable with Rules, but I have another idea. In Views, there is a filter called "User account: Last access". I'm using it for a "Who's online" block (see screenshot below). You could try to combine that filter it with other views filters or with block visibility conditions to adapt the block to your needs.

Hi, i see what you mean - this is great. I hooked it up contextually, and now it shows it both either by the last access time or boolean toggled by the login/logout rules. Disabled the old block and took its CSS class to the field. 

I consider it solved for now - thanks for this.

Edit: Or this combo, rather - maybe adding a filter by "last login time" helps too. Still tweaking it.