Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

piljac1's avatar
Level 28

Session lifetime not taken into account

Hi guys! I'm having a somewhat big problem right now. Apparently, you can set the session lifetime in config/session.php by changing the lifetime value (which is in minutes) directly or via the SESSION_LIFETIME env variable. By default, it is 120 minutes and I can see that clearly when inspecting by cookies in Chrome. The Expires / Max-Age date time is two hours after my last activity. However, I tried to increase and decrease the lifetime config value (directly and via the .env file), but it always remain 120 minutes when I look at the Expires / Max-Age date time.

Here's the steps I took when changing the lifetime value :

  1. Change the value
  2. Run php artisan config:clear
  3. Clear cookies inside the browser (Chrome) Application panel
  4. Refresh the page.

I also bumped the session.cookie_lifetime and session.gc_maxlifetime as I found in a StackOverflow thread, but it didn't do anything.

Thanks in advance guys!

P.S. Here's my current lifetime config (which doesn't work as intended, it remains 120 minutes)

/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/

// 1 week lifetime
'lifetime' => env('SESSION_LIFETIME', 10080),

'expire_on_close' => false,

Additionnal info : The expire_on_close config works as expected.

0 likes
5 replies
jlrdw's avatar
jlrdw
Best Answer
Level 75

After changing what does:

Config::get('session.lifetime');

show? And did you also place 10080 in .env.

1 like
piljac1's avatar
Level 28

I feel like a f***ing dumbass right now, I tried adding SESSION_LIFETIME in my .env when debugging initially, but that's the problem: I added SESSION_LIFETIME when it was already existent lower in my .env.

Sometimes when you think your bug is way deep, it's probably because you're looking way too deep. Benefiting from other people's thought process often solves the issue in a hurry, and that's what happened. Thanks a lot!

Shame on me!

lukasyelle's avatar

Maybe also try:

php artisan cache:clear

Sometimes that is also necessary for config changes

1 like
jlrdw's avatar

@piljac1 We all done that. Usually I take a short break, have a cigarette and coffee, and when I return to computer suddenly I see what's wrong.

1 like
piljac1's avatar
Level 28

I've been working a lot of overtime in the past 3 weeks, so I'll blame what happened on the fatigue haha.

Please or to participate in this conversation.