How to set session timeout in Laravel?

后端 未结 4 1079
礼貌的吻别
礼貌的吻别 2020-12-03 05:35

Is there an inherent way to setup sessions to expire after a certain time. My current setup seems to be expiring after 30 minutes and I would like to disable that or at leas

4条回答
  •  心在旅途
    2020-12-03 05:56

    Check your php.ini, it has a value for session.gc_maxlifetime (and also session.cookie_lifetime) that sets a limit on how long PHP will allow sessions to last. When Laravel sets the options, it passes cookie_lifetime as the value set in app/config/session.php.

    However, sessions are not expired immediately after the max lifetime is reached. What happens is after that amount of time has passed the session is then available to be removed by the garbage collector.

    To solve the issue

    One workaround is to check your php.ini file. You may have this variable defined: session.gc_maxlifetime. By default it is set to 1440. Just comment or delete it.

    From this time on you session may work properly using your session.php config values.

提交回复
热议问题