PHP 会话过期
我有一个会话,30 分钟不活动后或 23.4 小时后被销毁。
我遇到的问题是,无论活动如何,会话都会在 30 分钟后被销毁。因此,如果用户在 23.4 小时内持续处于活动状态,则会话应在这 23.4 小时内维持,然后被销毁,迫使用户再次登录,但会话会在 30 分钟后被销毁,即使用户在这 30 分钟内持续处于活动状态。
由于垃圾收集器查看的是修改时间而不是访问时间,因此会话将使用 time()
进行更新,以便当用户在网站上执行任何操作时都会更新修改时间。
这是 php.ini 会话设置:
Directive Local Value Master Value
session.cache_expire 30 30
session.cookie_lifetime 1800 1800
session.gc_divisor 1000 1000
session.gc_maxlifetime 84400 84400
session.gc_probability 1 1
session.save_handler files files
如果您需要任何其他会话 ini 设置,请告诉我。
任何对此的帮助将不胜感激。
谢谢
I have a session that after 30 minutes of inactivity is destroyed or after 23.4 hours is destroyed.
The problem that I have is regardless of activity the session is destroyed after 30 minutes. So if a user is constantly active within the 23.4 hours the session should be maintained for those 23.4 hours then destroyed forcing the user to login again, but the session is destroyed after 30 minutes even though the user is constantly active for those 30 minutes.
Because the Garbage Collector looks at the modified time and not the accessed time the session is being updated with time()
so that the modified time is updated when a user does anything on the site.
Here is the php.ini session settings:
Directive Local Value Master Value
session.cache_expire 30 30
session.cookie_lifetime 1800 1800
session.gc_divisor 1000 1000
session.gc_maxlifetime 84400 84400
session.gc_probability 1 1
session.save_handler files files
If you need any other of the session ini settings let me know.
Any help with this would be greatly appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
session.cookie_lifetime
设置为 30 分钟,因此 cookie 将在 30 分钟后过期,它不会在下一个请求时发送到服务器(30 分钟后),并且 php 将发出另一个会话因为他/她(php)没有在请求中收到它。session.cookie_lifetime
is set to 30 min , so the cookie will expire after 30 min , it whont be sent to the server on the next request ( after 30 min have passed ) , and php will issue another session since he/she(php) didn't recived it in the request .请勿触摸会话默认设置。保留默认值。
使用会话本身检查会话生命周期。
Do not touch sessions default settings. Leave default values.
Check session lifetime using session itself.