Level 40
You could set the global: SESSION_LIFETIME
vi .env
SESSION_LIFETIME=3
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am making a mobile number verification using OTP module. I want to associate the OTP with the mobile number for 3 mins only and want to forget the key beyond 3 mins. How can I do so?
I am using the following snippet.
Session::put(['otp' => $otp, 'mobile' => $number]);
You cannot expire it (nothing is running to check if it has expired)
You can only save what time it was created and then realise that it was too long ago when you come to check it.
Please or to participate in this conversation.