Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
808 views
in Technique[技术] by (71.8m points)

php - Laravel 4 session doesn't expire after lifetime limit

I've set 'lifetime' => 10 in my session config file, but it doesn't expire at all.

In laravel 3 with that setting, after logging in, when limit of 10 minutes is exceeded, the session expires properly and user is redirected to login again.

In laravel 4 it doesn't happen. After 10 minutes I can refresh, do anything and still session is valid.

I'm testing both on the same machine with analogical settings... What am I missing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I've got it. The problem was with the config pair lifetime and expire_on_close.

If expire_on_close is set to true, laravel 4 will ignore lifetime. I had:

'lifetime' => 1,
'expire_on_close' => true,

and in this case, session was valid after 1 min - it would only expire after closing browser. I changed it to:

'lifetime' => 1,
'expire_on_close' => false,

and now session is expiring after 1 min. no matter if browser is closed or not - close enough to what I've wanted.

The reason why I was confused and haven't figured it out earlier was that the comments there are unclear in that matter and that in Laravel 3 it worked differently...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...