In this small tutorial i will show you how to increase session timeout in laravel, in this example we can see how to set session lifetime in laravel.
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 2 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...