In this tutorial we will see you how to increase session timeout in laravel. In this example we can see how to set / increase session lifetime in laravel 6/7/8.
We can not set lifetime session for permanently but we can set in minutes for session expiration time. so here we will set 1 year time for session expire.
If you want to increase your session life time then we need to change in .env file and it is very easy to change it from configuration file in laravel. laravel provides you session.php file there is we can see 'lifetime' key option for setting time in minutes.
In session configuration file there is a also several option for set expire_on_close, encrypt, timeout and driver etc.
Here I will give you solution for increase session timeout in laravel.
We need to define value in minutes in your .env file as below:
<?php use Illuminate\Support\Str; return [ 'lifetime' => env('SESSION_LIFETIME', 120), ]
<?php use Illuminate\Support\Str; return [ 'lifetime' => 1 * (60 * 24 * 365), ]
In some conditions also happen cache issue, So, we need to clear it.
For clearing Cache, View, Routes in Laravel check below.
And, Now your session timeout time will be increased...
You may also like :