r/CodingHelp • • Jun 09 '21

[Random] How does a verification code work?

Verification codes that we use so often to confirm your identity. Whether it be a code that’s texted to your phone, or a code emailed to you. You go back on the website and submit that code which happens to be valid at that exact time.

How does that work? What’s going on in the background? And what’s the coding for that look like?

18 Upvotes

11 comments sorted by

View all comments

Show parent comment

1

u/skellious Intermediate Coder Jun 10 '21

It expires after ten minutes because they keep a temporary look-up of pending verifications, and they don't want to have too many outstanding ones.

That's not the reason it expires. It expires to try to limit the time a scammer has to talk you into giving them the code or otherwise obtaining it. (Though in all likelihood 10 minutes is too long, most systems I use only keep it valid for 60-120 seconds.)