Khawer Zeshan Khawer Zeshan - 4 months ago 37
PHP Question

Referrer URL in case if the link was clicked from email

I have a user registration process in which I send an email to the user for email verfication and to activate their account. Now when the

activate link
from the email is clicked, How do I get the referrer that tells me whether or not the user came to the page by clicking the link from the email?

Answer

Before you generate the email, you generate a unique token for that user. Then you'd append that token to the URL, and the page that does the verification checks the username and the verification token. If they match, then the user has verified their email.

For example, your email would contain a link to http://www.example.com/process.php?user=foo&validate_token=bar. Then your process.php page would check to make sure that the foo user's validation token is actually bar. If it is, then the user foo has had their email address validated.

Comments