Track user activity within a persistent session

Created on 7 January 2013, over 11 years ago
Updated 13 October 2023, 9 months ago

Hi, and first of all thanks for creating this module - you just saved me a bunch of time :) One of the challenges I have that I am looking to solve is as follows.

- The module adds an entry via hook_user_login / hook_user. This captures login history details when the user enters credentials and creates a brand new session.
- The maximum length of a Drupal session is controlled via settings.php, specifically:

ini_set('session.cookie_lifetime',  2000000);

- The cookie lifetime is 2 million seconds, or just over 23 days.


So... assuming my session table is not flushed out and the users continue to use the same browser, I'm only going to see their login activity once every 23 days since that's when they are forced to re-authenticate. What I want to do is to keep the long cookie lifetime but more closely track activity. This will involve measuring the length of time between activity and capturing a new 'login' event. For example, let's say a user uses the site at 8AM on a Friday for an hour, then comes back Friday night at 6PM. I'd want to track each of those as separate logins even though neither of them would hit the hooks because an actual authentication event is not taking place.

One of the primary reasons I want to capture this is so I can map the time of day and week when each user is most likely to be using the site, and then use that metric as an input to my email and other notifications so I send updates and digests when it's optimum for the recipient to see it and come back to the site.

Thoughts? Do any of you share my interest in this feature? I'm happy to contribute code to implement it but not before understanding if my code has a shot of being accepted and talking through design with the maintainers. Thanks!

✨ Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States rjbrown99

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024