Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How To Increase or Decrease Laravel Session Lifetime

Laravel comes straight out of the box with some very easy to access interchangeable variables. One of these variables is the application Lifetime variable or otherwise known as the ‘Session Lifetime’ variable. This variable can be changed to suit in an incremental or decremental fashion. In this article, we will make the way through the steps to increase the session lifetime of your Laravel app.

The article is split into two separate tutorials that explain how to increase or decrease the session lifetime for differing versions of Laravel.

Steps for Version 5.5.22 +

One of the new features of the later versions of Laravel is the session.php config files’ ability to pull in the session lifetime value from the .env file. In the following steps, the .env file is the only place we need to make the changes.

Step 1

Find the .env file in the root directory of your project.

Step 2

Look for the environment variable named SESSION_LIFETIME. This is usually (if untouched) set at 120 (minutes).

Step 3

Change the value to suit your requirements, remembering that a single integer of 1 is equal to 1 minute.

For example, to change the session lifetime to 6 hours, change the value to the following –

SESSION_LIFETIME=360

Steps for Version

In the earlier versions of Laravel, the session lifetime is set ‘inline’, within the config session.php file. Follow the steps to make changes to the value.

Step 1

Locate the session.php file within the project config folder.

Step 2

Locate the line with the ‘lifetime’ property on it, this usually has a value already assigned of 120.

Step 3

Change the integer value to meet the requirements of the session lifetime you require, remembering that each integer of 1 is equal to 1 minute.

For example, if you want to change the value to 4 hours, you should make the following changes –

'lifetime' => 240,

The post How To Increase or Decrease Laravel Session Lifetime appeared first on Code Wall.



This post first appeared on Code Wall - Web Development & Programming, please read the originial post: here

Share the post

How To Increase or Decrease Laravel Session Lifetime

×

Subscribe to Code Wall - Web Development & Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×