Increase php session time

前端 未结 5 418
没有蜡笔的小新
没有蜡笔的小新 2021-02-05 12:41

I am trying to increase my php session time to 6 hours.

Here is the code to increase the session time:

ini_set(\'session.gc_maxlifetime\', 60 * 60 * 6);          


        
5条回答
  •  深忆病人
    2021-02-05 13:20

    Increasing session.gc_maxlifetime via ini_set may not work if there is another script that runs (e.g. an other vhost) that uses the same session.save_path. The other script removes the sessions of all scripts by its own lifetime:

    Note:
    If different scripts have different values of session.gc_maxlifetime but share the same place for storing the session data then the script with the minimum value will be cleaning the data. In this case, use this directive together with session.save_path.

    Source: http://php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime

    Also be sure to change the setting before session_start(). If you have session.auto_start enabled, it is to late when you use ini_set.

提交回复
热议问题