PHP 中的永恒会话 [英] everlasting sessions in PHP

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

问题描述

是否可以将 PHP 会话配置为永不过期?我目前在 php.ini 中设置了默认的 24 分钟 - 我可以将其设置为几周或类似的时间,但我想知道是否可以将它们设置为无限生命周期?

Is it possible to configure PHP sessions to never expire? I currently have the default 24 minutes set in php.ini - I could whack this up to a couple of weeks or something like that but I was wondering if I can set them to infinite lifetime?

我想实现与 Stackoverflow 类似的效果:我永远不必在这里登录.这是通过永不过期的会话还是其他方式在 SO 上实现的?

I want to achieve a similar effect to Stackoverflow's: I never have to log in here. Is this achieved on SO with a never-expiring session or some other means?

此外,作为次要问题:如何清理过期的会话文件?如果有人创建了一个会话并且永远不会返回,那么哪个进程正在清理他们的过期文件?

Also, as a secondary question: How do the expired session files get cleaned up? If someone creates a session and never returns, which process is cleaning up their expired file?

推荐答案

通常,看似永久的会话有两件事:一个很快就会过期的会话,以及一个包含自动登录的长寿命 cookie令牌.

Normally, what appears to be an everlasting session is two things: a session, which expires pretty soon, and a very long-life cookie containing an auto-login token.

此 StackOverflow 问题中包含一系列关于会话和登录的大量回复:网站身份验证权威指南

There's a great series of responses on sessions and logging-in contained in this StackOverflow question: The Definitive Guide To Website Authentication

关于您关于何时清理会话的问题,有几个 php.ini 设置 用于控制何时触发会话的垃圾收集.

Regarding your question about when sessions are cleaned up, there are several php.ini settings for controlling when the garbage collection for sessions is triggered.

这篇关于PHP 中的永恒会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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