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

shan2590's avatar

Laravel session

// SESSION_LIFETIME is 30min //laravel 5.7

if user login then user did not perform any action after 15min can i get result as rest of 15 min inside middleware?

0 likes
11 replies
Snapey's avatar

middleware only runs when the user sends a request. At that time, their session is set back to 30 minutes because they interacted with the back-end.

So, nothing will happen when their session has 15 minutes left.

1 like
pauljp's avatar

@shan2590 Sugestions from a noob:

Cron a check logged user and last interaction.

Js countdown with ajax to interact with the backend.

1 like
shan2590's avatar

@sti3bas can't use DB. If the user logged and the user didn't do any click or enter (application in the idle period 30 min) after 30 min application logout (if user try to access application). is that enough ? do I need to check user session if expired then redirect login page?

shan2590's avatar

@snapey , I saw your answers regarding SESSION_LIFETIME , set SESSION_LIFETIME = 30. is that enough ? Do I want to check it again if session expire or not and redirect like thing inside middleware?

shan2590's avatar

@pauljp i did not found any noob people ! , you are right, But the thing is i can't use cron or ajax.

Snapey's avatar

Remember that session IS NOT CHECKED after the lifetime ends. It is checked when the user returns to the site and tries to continue. The framework does not find a valid session for the user so starts a new one.

What is the problem you are trying to solve?

1 like
shan2590's avatar

@snapey I'm trying to change user logging session time to 30min. Within this 30min if the user didn't do anything to in the application the session will automatically destroy and the user will logout.

Snapey's avatar
Snapey
Best Answer
Level 122

Then all you need to do is change the value in config/session.php

1 like

Please or to participate in this conversation.