retrieve php server session timeout

前端 未结 2 1169
北海茫月
北海茫月 2021-01-11 11:21

I want to retrieve the value of session.gc_maxlifetime from the PHP server settings ( the time after which the session expires after no activity ). Very import

相关标签:
2条回答
  • 2021-01-11 11:47

    session.gc_maxlifetime is not the time after which the session expires after no activity. gc here may be mean garbage collenction. As the php manual says,

    session.gc_maxlifetime specifies the number of seconds after which data will be seen as 'garbage' and potentially cleaned up. Garbage collection may occur during session start (depending on session.gc_probability and session.gc_divisor).

    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.

    For more refer to this post.

    0 讨论(0)
  • 2021-01-11 11:52

    That's where ini_get function comes in hand:

    $maxlifetime = ini_get("session.gc_maxlifetime");
    

    From manual we read:

    session.gc_maxlifetime integer session.gc_maxlifetime specifies the number of seconds after which data will be seen as 'garbage' and potentially cleaned up. Garbage collection may occur during session start (depending on session.gc_probability and session.gc_divisor).

    0 讨论(0)
提交回复
热议问题