Jump to content

User - Last Login DateTime


nbcommunication
 Share

Recommended Posts

Hi,

With the introduction of GDPR regulations, many of our clients with "webuser" systems we've developed need a way to email users that haven't logged-in in a while (18 months seems to be the standard) to ask them if they still want their user account.

For most of the systems we've developed, we've added a field to the user template which records the time when the user logs in, so we'll be able to develop this functionality.

It got me thinking, would this be a welcome addition to the core, accessed in a similar way to created/modified dates e.g. $user->lastlogin?

Were it to be implemented, it would be useful to be able to 'silently login' if using $session->login($username, $pass) or $session->forceLogin($username), in the same way you can bypass save hooks by passing in an option to $pages->save().

Cheers,

Chris - NB Communication

  • Like 8
Link to comment
Share on other sites

  • 10 months later...
  • 5 years later...

Thanks @bernhard!
Yesterday I was asking myself if my client has been active in the new system as promised and tried to find and filter a managerlog like in my CMS I used before PW. Now I installed ProcessLoginHistory for the future, but the passed data isn't there.
Having that functionality in the core from the installation on would make sense for this case, GDPR and system security in general.. in my opinion.

Otherwise or maybe anyway I have to use PW-profiles or similar for my new projects to have the basic extensions and customizations directly at hand.

  • Like 1
Link to comment
Share on other sites

3 hours ago, sebibu said:

Having that functionality in the core from the installation on would make sense for this case, GDPR and system security in general.. in my opinion.

Hello @sebibu,

you can find successful or failed logins under "Setup => Logs => Session" (/processwire/setup/logs/view/session/). You can search those logs for example by username.

It should also be possible to search those logs with the API: https://processwire.com/api/ref/wire-log/get-entries/

Hope this helps. ?

Regards, Andreas

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...
Posted (edited)
On 5/22/2024 at 4:37 PM, bernhard said:

@sebibu you can easily hook into https://processwire.com/api/ref/session/login-success/ and add the last login timestamp as $page->meta('lastlogin', time()) on the $user object (for example).

As usual when I have a new idea and wonder how to implement it with PW core only, Bernhard has left a forum post pointing into the direction how to accomplish what I am looking for, even before I posted the question in the forum. I guess I own you a beer or two at least now. 

Edited by cwsoft
  • Haha 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...