php Apache 使会话超时时间更长

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6324177/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:01:20  来源:igfitidea点击:

Apache making the session time out longer

phpapacheconfiguration

提问by Genadinik

I already altered my php.ini in Apache to have these settings:

我已经在 Apache 中更改了我的 php.ini 以具有以下设置:

session.gc_maxlifetime = 1440
session.cache_expire = 1500

But my sessions are not that long. The problem is that I am not certain which settings would "do the trick"

但我的会议时间并不长。问题是我不确定哪些设置会“起作用”

Ideally I am looking for the right configuration to have the session last 12 hours. Could anyone help me with that?

理想情况下,我正在寻找合适的配置来让会话持续 12 小时。有人可以帮我吗?

回答by Inna

do you also have set session.cookie_lifetime = 0 ? and maybe somewhere in your scripts or some included scripts the session lifetime is set to another value?

你也有设置 session.cookie_lifetime = 0 吗?也许在您的脚本或某些包含的脚本中,会话生存期设置为另一个值?

The default "0" value means that the cookie stays alive until the browser is closed. This is also the default value, if not set in php.ini. Source: http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime

默认的“0”值意味着 cookie 一直有效,直到浏览器关闭。如果未在 php.ini 中设置,这也是默认值。来源:http: //www.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime

回答by rzetterberg

Have a look at:

看一下:

session.cookie_lifetime x

Where x is the lifetime in seconds

其中 x 是以秒为单位的生命周期

Also, if you are on a shared host, make sure the session data under /tmp is not removed by the host with some sort of clean script. Some hosts clear /tmp every 10 minutes.

此外,如果您在共享主机上,请确保主机不会使用某种干净的脚本删除 /tmp 下的会话数据。有些主机每 10 分钟清除一次 /tmp。

回答by SuprMan

session.gc_maxlifetime is measured in seconds, so your setting of 1440 will expire after 24 minutes. (see: http://php.net/session.gc-maxlifetime)

session.gc_maxlifetime 以秒为单位,因此您的 1440 设置将在 24 分钟后过期。(见:http: //php.net/session.gc-maxlifetime

For 12 hour session I believe you need:

对于 12 小时的会议,我相信您需要:

session.gc_maxlifetime = 43200
session.cache_expire = 720
session.cookie_lifetime = 0