Laravel How to Increase/Decrease Session Lifetime
Hello Artisans, today I'll show you how to increase or decrease the session lifetime in our Laravel application. We all know that Laravel provides 2 hours of session lifetime as default. So, in today's tutorial, we'll see two examples of how we can modify the time of session lifetime.
At first, we'll increase the time from .env file. We just need to modify the time of SESSION_LIFETIME in minutes.
Like if we want to set the time for one year, the .env will look like the below:
SESSION_LIFETIME=525600 //24*60*365 = 525,600
In this example, we'll use session.php to increase/decrease the time of session. Let's see the below code.
<?php use Illuminate\Support\Str; return [ ..... 'lifetime' => 525600, ..... ];
That's it for today. I hope you've enjoyed this tutorial. Thanks for reading. 🙂