Retrieve last User login - are there any helpers?

Hello ^^,

are there any “ready to use” helerps to check for the last user login (not user specific) - I found $site->lastmodified() - but it seems it only uses the content folder $site->modified() | Kirby CMS

How can I check just for the last login?

Thank you as always :slight_smile:

There is no built-in check or log of user logins. You would have to log all logins somewhere using the https://getkirby.com/docs/reference/plugins/hooks/user-login-after hook. Or you use some logger plugin, not familiar with what exactly these log and might be overkill for your purpose.

If you want to be notified immediately after a user logs in, you can also choose to receive an email notification. I have integrated this function into a frontend login with a controller:
After a successful login, the user’s role is checked. In my example, an email is automatically sent for all non-admin logins. I only receive a notification when a regular user logs in to the frontend.

The notification can contain any information, for example:

  • Name and email address of the user
  • Role
  • Date/time
  • Referrer
  • User agent

In addition, a small rate limit can be built in to prevent a flood of emails in the event of repeated logins in a short timeframe.