I searched but could not find a way to set a timeout for the active session.
I’m using Laravel 10 and using the cookie
session driver since there are multiple servers. I want to control the session time with by 2 factors:
- A session timeout if the user is inactive for 30 minutes. For this
I’m settingSESSION_LIFETIME
in the .env to 30 - A session timeout of 1 hour irrespective of the user being active or inactive
I do not have any idea if there is any setting to manage the second condition as well or I need to manage it myself by storing the logged in time and checking it on every request.
Any help, hint or idea is appreciated.
2
Answers
In
config/session.php
you can add:And set the cookie:
Yes, you can achieve this using
middleware
.Something like that: