开发者

PHP event on session end?

I have in mind a chat-like page where it lists the online users and they can chat and whatnot. I've been looking at various questions here and articles on the internet about keeping track of o开发者_开发技巧nline users. Some said to have each page update the last seen time and make them appear offline if the difference between the current time and last seen time is larger than a certain number. Others said to ping something every few minutes.

What I was wondering, though, was if you could set up events on the end of a php session, so that I could have them appear online at the start of a session and offline when it ends. I'm assuming that because I haven't seen anything about it after looking, that there isn't a way, so what is the best way to do this?


You cannot rely on php session. Php session aren't supposed to be killed as soon as user has closed his browser. Even more - server-side (php specifically and its session engine) has no idea when user closed browser (and to be clear that even couldn't be caught in cases of power failure in user's house for example).

So - implement ping or latest-activity feature.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜