Laravel Increase Session TimeOut

Laravel increase or set session timeout or session lifetime; Through this tutorial, i am going to show you how to increase session timeout or session lifetime in laravel apps.

If you want to increase your session life time then you can easily do it from configuration file in laravel. laravel provide session.php there is a ‘lifetime’ key option for setting time in minutes. in session configuration file there is a also several option for set driver, timeout, expire_on_close and encrypt etc.

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

Laravel Increase Session TimeOut

There are two ways to increase or set session timeout or session lifetime in larave apps; as follows:

  • Using .env File
  • Using config File

Using .env File

Go to your laravel app root directory and find .env file. And you can simply define value in minutes in your env file; as follows:

SESSION_LIFETIME=525600

Using config File

Go to your laravel app config directory and find session.php file. And you can simply define value in minutes in your session.php file; as follows:

<?php
  
use Illuminate\Support\Str;
  
return [
  
    .....
  
    'lifetime' => env('SESSION_LIFETIME', 120),
  
    .....
  
]    

Leave a Comment