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.