How to Change Default Session Lifetime in Laravel
In this laravel 8 session lifetime tutorial, I will explain how to set session lifetime or how to increase session lifetime in laravel. This article goes in detail on how to increase session timeout in laravel. We will learn how to set session lifetime in laravel.
I wanna show you how to set session timeout in laravel. I am here to help you to give an example of laravel increased session timeout. You can easily increase session lifetime in laravel in many ways. But I am going to share one of them.
If you want to increase your session lifetime then you can easily do it from the configuration file in laravel. laravel provide
session.php there is a
lifetime a key option for setting time in minutes. Using that key we have to increase our session application session lifetime.
you can simply define value in minutes in your env file as below:
SESSION_LIFETIME=525600 //525600 means 60 * 24 * 365 = 525600
use Illuminate\Support\Str; return [ 'lifetime' => env('SESSION_LIFETIME', 120), ]
Hope it can help you.