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

nikunj001's avatar

need laravel code(not core php) to set session for 30 second

Hi actually i want to make a 30 second session from laravel . i know we can do session using core php .but i am not able to find the code for 30 second

0 likes
7 replies
realrandyallen's avatar

You can just set the SESSION_LIFETIME in your .env file - the issue is it's in minutes, not seconds

Snapey's avatar

Is a 30 second session worth having?

shez1983's avatar

in laravel you can flash your sessions for just one request - perhaps thats what you are wanting? but 30 sec session doesnt make sense until you tell us what you are trying to do

nikunj001's avatar

@SNAPEY - actually i have made a otp verification code in my project. And when i send my otp at that time i have to start my session as otp send . And yes i have also provided a otp resend code. But i want to make user to go back and type the number again and get the otp. if he is on my otp page for more that 30 second. so for that reason i want 30 second session.

Snapey's avatar

How will the user stay logged in once they have used their OTP code?

nikunj001's avatar
nikunj001
OP
Best Answer
Level 2

@SNAPEY - once the otp is entered my Users session will start and otp session will be destroyed.

And yes one more thing i have got an alternative for my given problem . which i have mention in this answer

Snapey's avatar

Then you don't want 30 second sessions because users session will end shortly after logging in

Please or to participate in this conversation.