简体   繁体   English

PHP会话在使用中到期

[英]PHP session expires while in use

Recently my webhost changed the PHP configuration. 最近,我的网络主机更改了PHP配置。 The only complaint I have is that sessions expire while in use. 我唯一的抱怨是会话在使用中到期。

Generally, I just write once to the session, but read many times, so I thought this may be because the filemtime wasn't changing, so every time I read, I also write by incrementing a counter. 通常,我只向会话写入一次,但读取多次,因此我认为这可能是因为filemtime并未更改,因此每次读取时,我也会通过增加计数器来写入。 Still nothing, after 24 minutes, whether the session is being used or not, it gets cleared. 24分钟后,无论是否正在使用会话,仍然没有任何内容被清除。

Any ideas on how to fix this? 有想法该怎么解决这个吗?

PHP constantly reads and writes the session data file when you start a session and end the script (or call session_write_close() ), so the file mtime should change. 当您启动会话并结束脚本(或调用session_write_close() )时,PHP会不断读取和写入会话数据文件,因此文件mtime应该更改。 There is no need to change the atime option of the filesystem. 无需更改文件系统的atime选项。

But things can easily go wrong beyond that, including having strange cronjob scripts running that delete session files. 但是除此之外,事情很容易出错,包括运行奇怪的cronjob脚本删除会话文件。 Without you complaining at the service desk, they will never fix it. 没有您在服务台抱怨的声音,他们将永远不会修复它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM