PHP会话默认超时

KB.*_*KB. 72 php session timeout default

默认情况下,PHP会话是否超时 - 即,如果我没有任何编码,用户最终会在一段时间不活动后"退出"?

Nie*_*sol 116

它取决于服务器配置或session.gc_maxlifetime中的相关指令php.ini.

通常默认值为24分钟(1440秒),但您的webhost可能已将默认值更改为其他内容.

  • 想知道为什么1440秒是默认的?... /sf/answers/2602377711/ (9认同)
  • 是创建后 1440 秒还是上次活动后 1440 秒? (2认同)

sut*_*her 16

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

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


hal*_*ush 8

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

  • @Mani什么时候是1440秒20分? (8认同)

Jer*_*oen 5

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

  • @rammanoj 20 分钟不活动。 (2认同)

Ela*_*van 5

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

session.gc_maxlifetime = 1440
(1440 seconds = 24 minutes)
Run Code Online (Sandbox Code Playgroud)


小智 5

您可以在 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
Run Code Online (Sandbox Code Playgroud)