how to verify user clicked on link in email that I sent him/her?

前端 未结 3 1643
借酒劲吻你
借酒劲吻你 2020-12-10 06:57

This is a more focused question triggered by an earlier posting here. I need to authenticate a user\'s email address by proving he/she has access to it. I\'ve copied below a

3条回答
  •  隐瞒了意图╮
    2020-12-10 07:41

    In your user database you need to have a staging users table (or in the main users table add a column indicating whether the user is active and default the indicator to "no"). When the user first registers, you generate a unique hash code from part of the user's info, e.g. Use md5 on user primary key and name (or some other set of user's variables which you can get back by decrypting) . Make this hash code a query string parameter in the link you send to the user. Finally, when the user clicks on the link, get the hashcode from the query string, decrypt it and match the decrypted values to the user row in your database. If a match is found, set the "active" indicator to true, and presto. Alternately, if you used a staging table, then move the user record to the "active users" table which you use to do your authorization on.

提交回复
热议问题