通过 .htaccess 在 PHP 中扩展会话超时

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/514155/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 22:57:08  来源:igfitidea点击:

Extending session timeout in PHP via the .htaccess

phpsessiontimeout

提问by Ian

I want to up the time my users will stay logged into my site without getting automatically logged out after a period of inactivity. I'm tracking the logged in status using PHP sessions.

我想延长我的用户保持登录状态的时间,而不会在一段时间不活动后自动退出。我正在使用 PHP 会话跟踪登录状态。

How can I set this, I'm trying to control this from my .htaccess file.

我该如何设置,我试图从我的 .htaccess 文件中控制它。

回答by ólafur Waage

You can't do that from the htaccess file butYou can change this line in your php.inifile.

你不能从 htaccess 文件中做到这一点,但你可以在你的php.ini文件中更改这一行。

session.gc_maxlifetime = 1440

Update: it seems to be possible, so i stand corrected

更新:这似乎是可能的,所以我坚持纠正

php_value session.gc_maxlifetime 3600

I haven't tried this out though.

不过我还没有试过这个。

回答by Asciant

You could also try changing the value at runtime using ini_set:

您还可以尝试使用ini_set以下方法在运行时更改值:

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