PHP会话超时值是0,但仍然会过期 [英] PHP session timeout is 0, but session still expiring

查看:261
本文介绍了PHP会话超时值是0,但仍然会过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行Apache 2.2的PHP与MySQL的最新版本。

I am running Apache 2.2 with the latest build of PHP and mysql.

在我的php.ini文件,我可以看到会话超时设置为0,这意味着会话保持住,直到浏览器关闭。

In my PHP.ini file, I can see the session timeout is set to 0, meaning the session stays live until the browser closes.

我已经注意到然而,有时在早晨到来时,和离开浏览器中打开并记录在一夜之间,会议似乎已过期。

I have noticed however, that sometimes when coming in in the morning, and leaving the browser open and logged in overnight, the session seems to have expired.

有没有会导致会话过期任何其他配置设置?我只是想玩玩的价值观和看到什么样的时间最适合我的网站。

Are there any other configuration settings that would be causing the session to expire? I just want to play around with the values and see what kind of time works best for my site.

非常感谢

主编

推荐答案

您可以试试:

http://in2.php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime

你可以把它放在你的PHP文件,第二个参数是之后的数据将被视为垃圾和潜在清理秒数。

you can put this in your PHP file, second parameter is number of seconds after which data will be seen as 'garbage' and potentially cleaned up. :

ini_set('session.gc_maxlifetime', 30*60);

希望这有助于!

编辑:

是的,我要指出,感谢您指出。

yes, i should mention that, thanks for pointing out.

的建议由威廉

调用该函数具有在session_start(前进行); - 威廉

"call to that function has to be made before the session_start(); – Willem "

例如:

<?php

 ini_set('session.gc_maxlifetime', 30*60);
 session_start();

 ?>

这篇关于PHP会话超时值是0,但仍然会过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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