问题
I am currently working on QR code generator. I would like to generate a QR code which will expire after an hour. Should I have to make the QR code to link to a website with php script? Or I could make it to set expired time at the QR code? Thanks for help.
回答1:
A QR code is, in itself, simply a text string that can be read by a camera. Text strings, in themselves, don't expire.
So, your QR code will need to contain some sort of expiring code. For example, you could put this kind of string into your QR code
https://wee.example.com/expire.php?code=abcd1234876ce067e
It would look like this.
The code (abcd1234876ce067e
in my example) is a randomly generated text string. It resists attack by cybercrooks because valid codes are hard to guess.
Then you write a little php program (called expire.php in this example) that looks up the code in a database. The codes table contains rows with the randomly generated code value and an expiration timestamp. If the code doesn't exist in the database, or its expiration time has passed, you ignore it. Otherwise you do whatever needs to be done with an unexpired code.
Notice there are also a few URL shortening services offering expiration. You could read this. https://www.guidingtech.com/15120/temporary-short-urls-expiry-date/ You could use one of these services to obtain a expiring short URL, then put it into the QR code.
来源:https://stackoverflow.com/questions/47598533/the-expire-time-of-qr-code