我想创build会话超时到6小时,但我的浏览器仍然在半小时内超时。
我在PLESK服务器上。
我更新了.htaccess
php_value session.gc_maxlifetime 21600 php_value session.cache_expire 21600 php_value session.cookie_lifetime 21600
这里是相关的PHPinfo:
Local Master session.gc_maxlifetime 21600 1440 session.cache_expire 21600 180 session.gc_maxlifetime 21600 1440
你的php_info() certificate这些设置已经被应用了。
你在Debian或Ubuntu上? 在这种情况下,有一个警告:Debian mantainers已经修补了PHP包,通过crontab清除未使用的会话。 (以上内容不仅适用于Debian / Ubuntu,取决于发行版的mantainers)
# /etc/cron.d/php5: crontab fragment for php5 # This purges session files older than X, where X is defined in seconds # as the largest value of session.gc_maxlifetime from all your php.ini # files, or 24 minutes if not defined. See /usr/lib/php5/maxlifetime # Look for and purge old sessions every 30 minutes 09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -print0 | xargs -n 200 -r -0 rm
因此,这种权力下放是基于全球环境而不是以每个进程为基础来完成的。
我看到两个解决scheme:
session_write_close()closures会话并再次打开它。 无论select哪条路线,我build议您保留您对.htaccess所做的修改。
让我们知道怎么回事 :-)
尝试在你的代码中进行。 如果你有任何包含header.php或config.php文件的话,可以把它添加进去:
ini_set("session.gc_maxlifetime", 21600); session_set_cookie_params(21600);