I need to track user logins so I know how often "UserA" is logging into my site. Can anyone recommend a method to do this? Module or code?
3 Answers
I think you are looking for User Stats module.
Provides commonly requested user statistics for themers, IP address tracking and Views integration. Statistics are:
- days registered;
- join date;
- days since last login;
- days since last post;
- post count;
- login count;
- user online/offline;
- IP address;
-
-
3
-
-
Just to close off this question I will share how I managed to track the user login times.
I simply wrote a module that added a table to the db and on login I would add the login/user event + date-time to the table.
Then I was able to access how many times and at what time users were logging in. This was something I wasn't able to get from the User Stats module.
-
Could you post the code or some elaborate on how you did it? Not sure where to begin w/ doing the same.– jay-essCommented Oct 6, 2015 at 17:36
-
@jay-ess which part don't you understand? Timestamp and UID are recorded to the custom database table on login. This info can then be used to analyse login counts and time patterns for users.– dibsCommented Oct 6, 2015 at 18:49
-
k. Will get working on which hooks, etc, and post some code if I can make it work. Thanks.– jay-essCommented Oct 6, 2015 at 19:02
-
You're right, "User stats" is not a solution for your question. But maybe you want to have a look at my answer to this question. If you'd change the "5" in it to eg 9999 (and possibly some other task configuration options), you might be close. Commented Aug 11, 2016 at 17:27
A simple module that tracks each time a user logs in and stores a historical record in your database. This data is then exposed to views so you can report on it if required.
Logs minimal data: user ID, and time logged in Ability to exclude users from tracking by role Hooks to allow fine-grained control over which logins get tracked Hooks to allow you to add information to the data stored Views integration
it's available on both Drupal 7, 8