User Login Log

If you need to build a log that keeps track of user’s login and logout, how do you accomplish this in a secure way? I’ve got it to work on the login timestamp, ip, and usernames. However, I am having some difficulty with capturing the logout timestamp.

Thanks for any suggestions!

You should have server actions for login and logout. Just set up a login table in your db and insert a new record after the login step.

For logout you could update the latest login record with logout details or you could have a separate table. Just update/insert after the logout step ( you’ll have to assign the user Id to a set value step before the logout as it won’t exist afterwards)


Thanks for explaining the reason the info to be inserted was always empty. I really appreciate your insight!

thanks @bpj exactly what I was after too. So nice and simple!

1 Like