Laravel Set or Increase Session Lifetime
Hello Artisan, today I'll talk about how you can set or increase the session lifetime in Laravel. Laravel provides us default session timeout of 2 hours. But sometimes we need to extend it. So, lets' see how we can increase the session timeout in our application.
Note: Tested on Laravel 9.2.
AS we know Laravel framework is also known as for highly customizable. So we can simply change the session timeout without any headache. By simply modify our .env file we can achieve it. If we look our .env file we can find a variable named SESSION_LIFETIME which is set to 120 like below
SESSION_LIFETIME=120
So here 120 means 2 hours because the timeout count as a minutes
60 * 2 = 120
So, if you want to increase our session lifetime for the next one week then our value will be
60 * 24 * 7 = 10080
We can also change the session lifetime through our session.php. We just need to update our below variable
'lifetime' => env('SESSION_LIFETIME', 120)
Just update the value of lifetime like below
'lifetime' => 10080
And it's done.
That's it for today. Hope you'll enjoy through this tutorial. Thanks for reading :)
Comment
Preview may take a few seconds to load.
Markdown Basics
Below you will find some common used markdown syntax. For a deeper dive in Markdown check out this Cheat Sheet
Bold & Italic
Italics *asterisks*
Bold **double asterisks**
Code
Inline Code
`backtick`Code Block```
Three back ticks and then enter your code blocks here.
```
Headers
# This is a Heading 1
## This is a Heading 2
### This is a Heading 3
Quotes
> type a greater than sign and start typing your quote.
Links
You can add links by adding text inside of [] and the link inside of (), like so:
Lists
To add a numbered list you can simply start with a number and a ., like so:
1. The first item in my list
For an unordered list, you can add a dash -, like so:
- The start of my list
Images
You can add images by selecting the image icon, which will upload and add an image to the editor, or you can manually add the image by adding an exclamation !, followed by the alt text inside of [], and the image URL inside of (), like so:
Dividers
To add a divider you can add three dashes or three asterisks:
--- or ***

Comments (0)