访问PHP中的活动会话 [英] Access active sessions in PHP

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

问题描述

如何获取服务器上所有活动PHP会话的列表,并从一个用户实例中访问它们?

How can I get a list of all active PHP sessions on a server and access them from within one user's instance?

激励性的案例是显示站点上所有当前活动用户的列表,其中用户名存储在每个用户的PHP会话中.

The motivating case is displaying a list of all currently active users on the site, where usernames are stored in each user's PHP session.

注意:我知道我可以通过数据库(甚至文件系统)创建自己的状态,但是我正在寻找一种利用内置PHP会话机制的方法.

Note: I know that I can create my own state via a database (or even the filesystem), but I'm looking for a way to utilize the built-in PHP session mechanisms.

推荐答案

看到响应,尽管有可能,但这并不意味着您应该这样做.会话的存储格式没有记录,并且可能随时更改(即使在次要版本之间也是如此).

Seeing the responses, though it's possible, it doesn't mean you should do it. The format in which the sessions are stored is not documented and may change at any time (even between minor versions).

正确的 方法是实现您自己的会话处理程序.其实并不难.

The correct way to do this is to implement your own session handler. It's not that hard, really.

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

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