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

11

u/Nightcorex_ Jun 09 '21

You send a request to the server like: "Hey, sent me a verification code please"
The server generates a Verification code for your account, then creates the EMail, SMS, etc and sends it to you.
Then you enter the code, server checks if that data is equal and bam.

That's it

3

u/varazdates Jun 09 '21

But how do the two systems communicate with each other? How does one side know that the verification code is correct and valid? There must be some sort of communication and teamwork between the two right?

4

u/Dogburt_Jr Jun 09 '21

There's only one system, the website/server. It creates a code valid for a limited time, then sends it to a channel only you should have access to (phone/email), then awaits the client to input the code. It has dual purpose to make bots harder to use for logins and it's an extra layer of security.