会话超时在PHP代码和htaccess中? [英] session timeout in php code and in htaccess?

查看:70
本文介绍了会话超时在PHP代码和htaccess中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们用来在php中设置会话超时的内容.我发现了以下内容:

What we use to set the session time out in php. I found following:

ini_set(session.cookie_lifetime, 3600);
ini_set(session.gc_maxlifetime, 3600);

在php中设置会话超时是正确的方法吗?还是有什么方法可以在htaccess文件中设置超时时间?

Is it right way to set timeout for session in php? Or is there any way we can set the time out in htaccess file?

也许这是一个简单的问题,但我并没有真正的答案,甚至在SO,Google和php.net上也尝试过,但没有直接的解决方案或代码.

Maybe its a simple question, but I am not really able to get the answer, even tried on SO, Google and php.net but no straight solutions or code for this.

推荐答案

我已通过在.htaccess文件中添加以下代码来解决此问题.

I have resolved this issue by adding following code in my .htaccess file.

<IfModule mod_php5.c>
    #Session timeout
    php_value session.cookie_lifetime 1200
    php_value session.gc_maxlifetime 1200
</IfModule>

谢谢!

这篇关于会话超时在PHP代码和htaccess中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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