How to Increase Session Timeout in Laravel 7?

Laravel 7

Nicesnippets

27149

11-05-2020


Hi Guys,

Today, I will show you how to increase session timeout in laravel 7. You will learn you set seeeion lifetime in laravel 7. We will help you to give example of laravel 7 increase session timeout.

If you increase session time in laravel 7 then you can use bellow two solution. Two solution in first solution in using .env file and second solution in config file used.

You can simply to use increase session lifetime in laravel.

Basically, you can not set lifetime session for forever but you can set in minutes for session expiration time. so i will set 1 year time for session expire.

60 * 24 * 365 = 525600

Here i will show how to increase lifetime from env file and configuration file. so let's see both example as bellow:

Example 1 : .env File


You can easy to define value in minutes in your env file as bellow.

.env

SESSION_LIFETIME=525600

config/session.php

<?php

use Illuminate\Support\Str;

return [

.....

'lifetime' => env('SESSION_LIFETIME', 120),

.....

]

Example 2: Using Config File

config/session.php

<?php

use Illuminate\Support\Str;

return [

.....

'lifetime' => 1 * (60 * 24 * 365),

.....

]

It will help you...


Recommended Posts