通过 .htaccess 延长 PHP 中的会话超时

发布于 2024-07-13 17:05:30 字数 113 浏览 7 评论 0原文

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

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

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.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

帅气尐潴 2024-07-20 17:05:30

您无法从 htaccess 文件执行此操作,但您可以在 php.ini 文件中更改此行。

session.gc_maxlifetime = 1440

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

php_value session.gc_maxlifetime 3600

我还没有尝试过这个。

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

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.

百善笑为先 2024-07-20 17:05:30

您还可以尝试使用 < 在运行时更改该值代码>ini_set

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

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

ini_set('session.gc_maxlifetime', '3600');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文