Player login - logout

Hey everyone, I am looking to use a database to store my player stats. I don’t want to update the database each time the player gets XP or adjust health, inventory, etc.

I am looking for a way to only update the database when the player logs out, is there a way for this?

I was thinking of possibly making the player invisible, and pop up the log out screen when the player hits logs out, then update the database at that time.

Let me know what you think. Thanks!