Copy link to clipboard
Copied
Hi,
i am uisng CF7 and develope the page with have cfmail send the url to customer but i don't want them to see the ID from the link. Is there the way to hash, encode, decode for not letting them see an ID but when they click on the link, the ID will propertly decode and retireve the record from the table?
thanks
kt
Copy link to clipboard
Copied
Yes, you could use the Hash function (added in MX7). Since you can't "unhash", you would need to Hash the ID and store the resulting string somewhere. The email to the customer would contain the string as a parameter in the link you send, and when they click the link you compare the value with those you saved.
1) Add a field to your database table containing the IDs, call it something like IDHashed
2) Do a query to get all your ID values and loop over the result
3) cfset ThisHashedString = Hash(current_ID_value, "SHA") and save the result in the field you added, i.e. IDHashed
4) When creating the link to go in the email, use the hashed string as a parameter
5) When someone clicks the link, it goes to your page that sees the parameter, hopefully validates/sanitizes it, and queries your database for a matching value in the field you added in step 1.
I'm all for "if it ain't broke don't fix it", I'm still running CF 9.0.1. But MX7? That's really old....
Copy link to clipboard
Copied
i guess i can use uuid instead?
Copy link to clipboard
Copied
Do you mean use the CreateUUID function? Yes, you could. I'm not sure when that was added, the Livedocs don't say when a function was added, as they do for tags. Whatever works in MX7 should suffice.