How to detect that a player reconnected?

Are their ways to detect that a player reconnected and to know which, and if yes, what are the most efficient ones? I think I have one in mind, that would be to store in a storage all the members of a ticking scoreboard during three tick and compare them each tick to see if it started increasing while it didn't before but I think it sounds unoptimised
Continue to help post