按用户设置 php 会话超时
可以在 php 中由用户设置会话超时吗?
示例:2 个用户在我的网站上注册。我希望每个用户都可以设置自己的会话超时。
It´s possible to set session timeout by user in php?
Example: 2 users are registred in my site. I want that each user can set their own session timeout.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以为每个用户设置自定义会话超时。您可以使用 中描述的方法如何在 30 分钟后使 PHP 会话过期?,而是存储绝对过期时间:
这里可以为每个用户设置不同的
$customSessionLifetime
。只需确保其值小于或等于 session.gc_maxlifetime 和 session.cookie_lifetime(如果您使用 cookie 作为会话 ID)。Yes, you can set a custom session timeout for each user. You can use the method as described in How do I expire a PHP session after 30 minutes? but store the absolute expiration time instead:
Here
$customSessionLifetime
can be set differently for each user. Just make sure that its value is less than or equal to session.gc_maxlifetime and session.cookie_lifetime (if you use a cookie for the session ID).