How To Increase Session Timeout Limit In Laravel 8?


This tutorial goes into detail on How to Increase Session Timeout in Laravel 8. you will learn how to set the session lifetime in laravel. We are how to set session timeout in laravel 8. we will help you to give examples of laravel increase session timeout in this tutorial.

You can easily increase session lifetime in laravel 8 version.

laravel session lifetime forever then you can easily do it from the configuration file in laravel 8. laravel provides a session.php there is a 'lifetime' key option for setting time in minutes. In the session configuration file, there are also several options for a set driver, timeout. Then update session value in laravel.

Basically, you can not set a lifetime session forever but you can set in minutes for the session expiration time. so I will set 1 year's time for the session to expire on laravel session lifetime.


60 * 24 * 365 = 525600


Here I will show how to increase lifetime sessions in laravel from .env file and configuration file. so let's see both examples as bellow:

[Lifetime Session] How To Increase Session Timeout Limit In Laravel 8?
Solution 1: Using .env File

You can simply 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),
  
    .....
  
]
Solution 2: Using Config File

config/session.php

<?php
  
use Illuminate\Support\Str;
  
return [
  
    .....
  
    'lifetime' => 1 * (60 * 24 * 365),
  
    .....
  
]

I hope it can help you...

Leave a Reply

Your privacy will not be published. Required fields are marked *

We'll share your Website Only Trusted.!!

close