如何使 php 会话永不过期(在 conf 文件中,没有代码)

VaT*_*aTo 3 php session

我想将会话过期的时间管理为永远。

我必须在 php 配置文件中更改什么,以便此更改是永久性的,而且我不必在我编写的所有代码中都实现它?

在我对 php 文件进行更改后,是否需要重新启动 apache 才能使更改生效?

Nit*_*tin 7

除非您不在 php 中使用垃圾收集,否则不可能无限地存储会话。您可以尝试设置 php ini 设置并将时间设置为 10 年

// set the max life time, after this, session is seen as garbage
session.gc_maxlifetime=315360000
Run Code Online (Sandbox Code Playgroud)

如果您启用了 cookie:

session.use_cookies=1
#session.use_only_cookies=1

// set the cookie expiration as well
session.cookie_lifetime=315360000
Run Code Online (Sandbox Code Playgroud)

为避免 Int 溢出,请勿使用大于 2,147,483,647 的值,因为这是 Int32 可以容纳的最大值。