如何使php会话永不过期(在conf文件中,没有代码) [英] How can I make a php session to never expire (in the conf file, no code)

查看:47
本文介绍了如何使php会话永不过期(在conf文件中,没有代码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想管理一个会话永久终止的时间.

I would like to manage the time that a session expire to be forever.

我必须在php配置文件中进行哪些更改,以便此更改是永久性的,因此我不必在我编写的所有代码中都实施此更改?

What do I have to change In the php configuration file so this change is permanent and I don't have to implement this in all the code I write?

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

After I make a change in the php file, do I need to restart apache for the changes to take effect?

推荐答案

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

It is not possible to store the session infinitely unless you do not use garbage collection in php. You could try to set the php ini settings and set the time to 10 years

// set the max life time, after this, session is seen as garbage
session.gc_maxlifetime=315360000

如果您启用了Cookie:

If you have cookies enabled:

session.use_cookies=1
#session.use_only_cookies=1

// set the cookie expiration as well
session.cookie_lifetime=315360000

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

To avoid Int overflow, do not use a value larger than 2,147,483,647 as this is the max an Int32 can hold.

这篇关于如何使php会话永不过期(在conf文件中,没有代码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆