What php.ini settings are required to allow a session to remain active for approximately two days?

前端 未结 5 1085
天命终不由人
天命终不由人 2021-01-13 07:53

http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime

says that a session.cookie_lifetime of 0 \"goes until the browser is closed\". Is

5条回答
  •  迷失自我
    2021-01-13 08:41

    Short (but slightly inaccurate) solution

    Set session.gc_maxlifetime to 172800 and session.cookie_lifetime to 0.


    Extended and more accurate solution

    In general, session.gc_maxlifetime is the configuration to control the session’s life time. So setting that directive to 172800 will make the session to expire after 172800 seconds (theoretically). But as the calculation of the age of a session is slightly odd, you might want to implement a more accurate expiration scheme. See my answer to How do I expire a PHP session after 30 minutes? for more information.

    And setting the session ID’s cookie lifetime to 0, the cookie will be valid until the browser is closed.

提交回复
热议问题