dsv768456 2013-02-04 11:14
浏览 33

PHP session.save_path&session.gc_maxlifetime行为

Sorry if this has been asked elsewhere, but I can't find the answer.

I recently made a site for which I've made significant use of session variables for the first time. I've never bothered to adjust the PHP session configuration before because it hasn't been necessary, session variables have worked as desired. For this site, I wanted to control the lifetime of sessions, so I needed to adjust gc_maxlifetime. As there seems to be no 0 or off setting, I have set it to 31536000 (365 days) with the intention of controlling expiry using PHP script.

I'm setting gc_maxlifetime via a local php.ini file, which my host allows. I'm also setting save_path via this file as gc_maxlifetime doesn't seem to work if it's not set. I presume this is because when save_path has no value a default /tmp folder for all users (this a shared server) is used and therefore you shouldn't be able to adjust the lifetime for all users.

And this all seemed to be working fine. I had two save locations, one for the main site and one for the CMS, at /absolute/hosting/path/tmp/session and /absolute/hosting/path/tmp/session/admin, phpinfo showed the correct values, and looking in the relevant folders I could see a bunch of session files. However, after a week or two (I don't exactly how long) the session functionality of my site stopped working altogether. New sessions were not being created at all. To fix it I have resorted to removing the save_path from my php.ini file, but now my sessions only last the default 24 minutes.

My initial thoughts were that there might be some file or folder size restrictions within the /tmp folder, but I wouldn't have a clue how to change that (presumably it would be an Apache thing that I'd need my hosting company to change), and it doesn't make much sense anyway, the files are small (1997 files, 17KB for the main site, 41 files, 9KB for the CMS), and the CMS carried on working for a week or so after the main site, before failing in the same way.

Does anyone have any idea what the cause of this might be?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大