php PHP会话默认超时

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9904105/
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 07:53:27  来源:igfitidea点击:

PHP sessions default timeout

phpsessiontimeoutdefault

提问by KB.

Do PHP sessions timeout by default - ie without any coding on my part would a user eventually be "logged out" after some time of inactivity?

PHP 会话是否默认超时 - 即如果我没有任何编码,用户在一段时间不活动后最终会“注销”吗?

回答by Niet the Dark Absol

It depends on the server configuration or the relevant directives session.gc_maxlifetimein php.ini.

这取决于服务器配置或相关指令session.gc_maxlifetimein php.ini

Typically the default is 24 minutes (1440 seconds), but your webhost may have altered the default to something else.

通常默认值为 24 分钟(1440 秒),但您的虚拟主机可能已将默认值更改为其他内容。

回答by suther

You can change it in you php-configuration on your webserver. Search in php.inifor

您可以在您的网络服务器上的 php-configuration 中更改它。搜索在php.ini

session.gc_maxlifetime()The value is set in Seconds.

session.gc_maxlifetime()该值以秒为单位设置。

回答by haltabush

Yes, that's usually happens after 1440s (24 minutes)

是的,这通常发生在 1440 秒(24 分钟)之后

回答by Elangovan

http://php.net/session.gc-maxlifetime

http://php.net/session.gc-maxlifetime

session.gc_maxlifetime = 1440
(1440 seconds = 24 minutes)

回答by rafee_que_

You can set the session time out in php.ini. The default value is 1440 seconds

您可以在 php.ini 中设置会话超时。默认值为 1440 秒

session.gc_maxlifetime = 1440

; NOTE: If you are using the subdirectory option for storing session files
;       (see session.save_path above), then garbage collection does *not*
;       happen automatically.  You will need to do your own garbage
;       collection through a shell script, cron entry, or some other method.
;       For example, the following script would is the equivalent of
;       setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
;          find /path/to/sessions -cmin +24 -type f | xargs rm

回答by Jeroen

Yes typically, a session will end after 20 minutes in PHP.

是的,通常情况下,会话将在 PHP 中 20 分钟后结束。