2009年9月14日星期一

Re: [fw-mvc] solution for online user list

The way I have tackled this in the past (without ZF) was to create a table that would update the user timestamp every time an update would occur. This allowed the who's online section to show up with the amount of users that have updated data the last x minutes (it was 10 for me). Later on I found out that this was really resource hungry so I combined the table with a caching mechanism which was updated every 10 minutes. The last update field was in the users table to save the extra update (if we were using different tables) upon data update. The online table was the cache for me.

You can do what you want with a controller plugin I believe. Just pull data from the online table and refresh the online table every x amount of time from your users table. I am pretty sure that invisionpower uses a similar mechanism if not that.

I hope this helps.


The contents of this message may contain confidential or privileged information and is intended solely for the recipient(s). Use or distribution to and by any other party is not authorized. If you are not the intended recipient, copying, distribution or use of the contents of this information is prohibited.


On Mon, Sep 14, 2009 at 20:16, Ralph Schindler <ralph.schindler@zend.com> wrote:
The easiest thing for you to do is mark the user object/record with the time they last logged in, perhaps in your AuthController.  Then when they log out, you can remove that timestamp from the record.  You could also achieve the same thing with a user_login table that would keep track of logins and logouts.  With this information, you can then query the database to show who recently logged in.

Another alternative is to switch to Zend_Session_SaveHandler_DbTable. If you were to start storing sessions in the database, you could query this table for that kind of information.  Unfortunately, you'd have to do some serious parsing of the session information to pull out user names.  That means this would likely be a pretty expensive task.

Check around the web, I think others might have tried similar tricks to solve the "who is logged in now" problem.

-ralph


sina miandashti wrote:
i completely build a smart app with zf and build its user interface
with zend_auth

i want to show list of online users at bottom of the page
like forums.invisionpower.com


any solution or example codes or tutorial ?


没有评论: