I would like to get a list of every login of a user. I know I can get a certain user with craft.users() but as far as I have seen, I get data for lastLoginDate only.

Is there a way to get a complete list of all logins? Is this information even stored?

1 Answer 1


Craft only stores the most recent login date for users (i.e. the lastLoginDate). To get a list of all users and their last login date, you could do something like this:

{% set users = craft.users.can('accessCp').all() %}

        <th>Last login</th>
    {% for user in users %}
            <td>{{ user.username }}</td>
            <td>{{ user.lastLoginDate|default ? user.lastLoginDate|date('Y-m-d H:i:s') }}</td>
    {% endfor %}

If you need to retain a more comprehensive login history, as opposed to only the most recent login date, you could try the Audit plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.