How to Set or Increase Session Lifetime in Laravel

In this tutorial you will learn about the How to Set or Increase Session Lifetime in Laravel and its application with practical example.

In this How to Set or Increase Session Lifetime in Laravel I will show you how to set or increase the session timeout or session lifetime in your laravel project. In laravel the session-timeout defines the default session timeout interval for all sessions. The session timeout is defined in minutes. In this tutorial you will learn following topics:

  • How to Set or Increase Session Lifetime in Laravel
  • What is default session time in laravel?
  • How does laravel session expire?

How to Set or Increase Session Lifetime in Laravel

In laravel if you want to set session lifetime for 1 year you can do this as following:

How to Set or Increase Session Lifetime in Laravel

Using .env File

If you set the session timeout in the .env file. The config directory has a session.php. In this file, the session timeout of your laravel web application is set in this way.

Using Config File

O open config/session.php file and set session timeout as following:

What is default session time in laravel?

The cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means “until the browser is closed.” Defaults to 0.

How does laravel session expire?

If you want laravel session to immediately expire on the browser closing then set that option. | */ ‘lifetime’ => 4320, ‘expire_on_close’ => false, if you want to set session lifetime per user, you need to set this value before logging in the user.

In this tutorial we have learn about the How to Set or Increase Session Lifetime in Laravel and its application with practical example. I hope you will like this tutorial.