在线显示用户列表 [英] show list of users online

查看:75
本文介绍了在线显示用户列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何列出登录系统的用户?


也许在应用程序属性中保存会话ID列表?

How can i list the users logged into the system?

Maybe save the list of session id in application attribute?

推荐答案

Yukino写道:
Yukino wrote:

如何列出登录系统的用户?


也许在应用程序属性中保存会话ID列表?
How can i list the users logged into the system?

Maybe save the list of session id in application attribute?



简短回答 - 你不能。你可以告诉别人什么时候登录,但是如果他们还在网站上则没有




更长的答案 - 不,没有应用程序属性。您可以实现自己的会话处理程序,然后可以在数据库中保存登录ID(或者甚至是所有会话数据),并在

会话已结束。这有点工作,但是一旦你让它工作了你

你不需要在你的其他页面上做任何事情(除了正常的

之外的东西)比如调用session_start)。


更容易,但通常需要更多的工作就是让你的登录页面向数据库添加一行,以及你的注销代码去掉它。然后每个

页面,在session_start()之后,可以使用

当前时间戳(可能都在一个包含的文件中)更新行


有一个每隔几分钟运行一次的cron作业并删除任何更多的条目

而不是x分钟 - 其中x与你的会话超时值相同,

适用于那些没有退出的人。


现在你可以计算表格中的行数并知道记录了多少行

。不是万无一失 - 但由于HTML是一种无状态协议,所以没有

保证这个人甚至还可以打开他的电脑(也就是说,他可能只需要在没有注销的情况下放弃
)。


-

==================

删除x来自我的电子邮件地址

Jerry Stuckle

JDS计算机培训公司
js ******* @ attglobal.net

==================

Short answer - you can''t. You can tell when someone logged on, but not
if they''re still on the site.

Longer answer - no, there are no "application attributes". You can
implement your own session handler, which can then save the login id (or
even all of the session data) in a database, and clean it up when the
session is closed. It''s a bit of work, but once you have it working you
don''t have to do anything on the rest of your pages (other than normal
things like calling session_start).

Easier, but generally requiring more work would be to have your logon
page add a row to a database, and your logoff code remove it. Then each
page, right after the session_start(), could update the row with the
current timestamp (which could all be in an included file)

Have a cron job which runs every few minutes and deletes any entry more
than x minutes old - where x is the same as your session timeout value,
for those who do not log out.

Now you can count the rows in your table and know how many are logged
on. Not foolproof - but since HTML is a stateless protocol, there is no
guarantee the person even still has his computer on (i.e. he might have
just hut down without logging off).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


Jerry Stuckle写道:

Jerry Stuckle wrote:


简短回答 - 你不能。您可以告诉某人何时登录,但如果他们仍然在网站上,则不会告诉他们。
Short answer - you can''t. You can tell when someone logged on, but not
if they''re still on the site.



实际上,你可以。它被称为信标。黑客一直都在使用它。


问题是,你的技术更精通的用户会看到它,并且变得真实。

生气。大多数人不喜欢你*监控*他们的活动 -

即使你觉得你的动机是良性的。


有一个号码如何做到这一点,但最好的方法似乎是

只需要一个客户端脚本,每隔一段时间发送一个URL请求

来刷新图像(可见或不可见,但最好是可见的 - 平静

techie nerves)。例如:


if(sTime(sNow + 15)){

MyImage.src =" myimage.php?" + sTime +"&" + sToken;

}


然后,让PHP文件生成图像并记录请求。


Actually, you can. It'' called a "beacon" and hackers use it all the time.

The problem is that your more tech-savvy users will see it, and get real
pissed off. Most folks don''t like for you to *monitor* their activity -
even if you feel that your motives are benign.

There are a number of ways to do it, but the best one seems to be to
simply have a client-side script that sends a URL request every so often
to refresh an image (visible or not, but preferably visible - to calm
techie nerves). For example:

if (sTime (sNow+15)){
MyImage.src = "myimage.php?" + sTime + "&" + sToken;
}

Then, have the PHP file generate the image and log the request.


rf写道:
rf wrote:

" Sanders Kaufman" < bu *** @ kaufman.netwrote in message
"Sanders Kaufman" <bu***@kaufman.netwrote in message


>问题是你的技术更多 - 精明的用户会看到它,并得到真正的生气。即使你觉得你的动机是良性的,大多数人也不喜欢你*监督他们的活动 -

>The problem is that your more tech-savvy users will see it, and get real
pissed off. Most folks don''t like for you to *monitor* their activity -
even if you feel that your motives are benign.



如果我看到我的网络灯定期闪烁,我会宣布

网站被破坏并立即离开。如果我是必需的使用该网站我会向管理它的人投诉


If I saw my network light flashing at regular intervals I would declare the
site broken and leave instantly. If I were "required" to use the site I
would complain to those who administer it.



是的 - 那里有很多疯狂的人,极度偏执。


但我已经发现最好让那些害怕网络的人们继续在黑暗中独自畏缩。


如果脚本活动和闪光灯吓到你了 - 网页会给你缉获




....谁想要*那个*作为客户群? br />

Yeah - there''s a lot of crazy folks out there, paranoid as hell.

But I''ve found that it''s best to allow folks who are afraid of the web
to just go ahead and cower in the darkness, alone.

If scripting activity and flashing lights scare you - the web will give
you seizures.

.... and who wants *that* as a customer base?


这篇关于在线显示用户列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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