-1

I'm sending a confirmation email but i don't know how to confirm account when link is clicked?

When user click on the link i send, i want to extract the query string token and compare the token with the token in database. How do i do this?

Thanks guys!

Lucas Senechal
  • 300
  • 1
  • 3
  • 15

1 Answers1

0

There are different approaches! Have a look at the follwing approach:

Generate a unique random unique string which would be used as the token for generating random string find reference in question here

Store this token in database and send the link with this token attached to the link as query string.

When user click on the link you sent, extract the the query string token compare the token with the token in database.

If the token matches email is validated!!

e.g.Suppose Generated token is 5DTI72EO6SFU215DTI72EO6SFU store it in database and generate the link as

mydomain.com?action=validateemail&user=theuser&token=5DTI72EO6SFU215DTI72EO6SFU

Don't forget to remove token from database and update the email verified status!! hope that helps.

Community
  • 1
  • 1
Arjun
  • 3,248
  • 18
  • 35