我的课程将持续多长时间? [英] How long will my session last?
问题描述
有人可以从下面的数据中告诉我我的会话将持续多长时间吗? -我不确定哪个告诉我
Can someone please tell me how long my session will last from the data below? - I'm not sure which one tells me
session.auto_start Off Off
session.bug_compat_42 Off Off
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_httponly Off Off
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 1000 1000
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.hash_bits_per_character 5 5
session.hash_function 0 0
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /var/lib/php/session /var/lib/php/session
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid 0 0
推荐答案
In general you can say session.gc_maxlifetime specifies the maximum lifetime since the last change of your session data (not the last time session_start
was called!). But PHP’s session handling is a little bit more complicated.
因为会话数据被仅由 session_start
调用的垃圾收集器删除了 session.gc_probability 由 session.gc_divisor 划分.默认值为1和100,因此垃圾收集器仅在所有session_start
调用中的1%中启动.这意味着即使会话在理论上已经超时(会话数据的更改时间已超过 session.gc_maxlifetime 秒),会话数据的使用时间也可以更长.
Because the session data is removed by a garbage collector that is only called by session_start
with a probability of session.gc_probability devided by session.gc_divisor. The default values are 1 and 100, so the garbage collector is only started in only 1% of all session_start
calls. That means even if the the session is already timed out in theory (the session data had been changed more than session.gc_maxlifetime seconds ago), the session data can be used longer than that.
由于这个事实,我建议您实现自己的会话超时机制.请参阅我对方法的回答我会在30分钟后使PHP会话到期吗? 以获取更多信息.
Because of that fact I recommend you to implement your own session timeout mechanism. See my answer to How do I expire a PHP session after 30 minutes? for more details.
这篇关于我的课程将持续多长时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!