Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

abdulrafey38's avatar

QR code in Laravel

Hi guys, i need some help regarding my project. I want to generate a qr code which students can scan from their mobile application to mark attendance, i am successfully able to generate a qr code but now i want to limit it for 2 or 3 minutes to be valid after that it will destroy for some security purposes how to achieve it, because uptil now if some person clicks the image of QR code and use it after some time his/her Attendance submitted successfully even after a day. I use laravel technology for web Portals and Android studio for my mobile application

0 likes
3 replies
willvincent's avatar

Seems a pretty easy problem to solve.. Generate a QR code that points to a URL with a time-constrained token.

  1. So first, create a new token in the DB with an expiration 3min in the future, or whatever.
  2. Setup a route that takes a token as a parameter: my-qr-route/{token}
  3. Look up the token, validate it's not yet expired, allow submittal.
  4. Remove expired tokens with a cron job.
abdulrafey38's avatar

I have a comma separated string of parameters in my qr code which i have to extract on my Android side than split it on the basis of comma and put it into database plus i am a beginner to laravel

Snapey's avatar

you want the verification to be done in the mobile application or the laravel application?

You can create a signed url in laravel which can be time limited, but this can only be verified by the Laravel application.

Please or to participate in this conversation.