开发者

Find user is online or not

In my project i have to implement an interface which shows whether a particular u开发者_如何学Pythonser is online or not as in social networking site(like orkut and facebook)


If you are using ASP.NET and the membership provider there are a bunch of different implementations. Here is a link to one:

http://blog.dreamlabsolutions.com/post/2009/07/13/ASPNET-Membership-Show-list-of-users-online.aspx

If you are not then you will need to be storing when users sign in to your system and keep track of everytime they are 'active' somewhere. I have done this using a the global cache but it really only works for single server solutions. You will need to move to DB storage if you want to use multiple servers but then that is pretty much what the ASP.NET membership will provide you out of the box with very little coding.

You can choose how to write to your datastore (such as cache) and expire 'sessions' based on how ever you want such as a specific time period of inactivity, the Session_End event, a logout command, etc...


The mechanism you must use is the Session_Start and Session_End events in your application. To get the end event to be called reliably, use the Session.Abandon method when your users sign out.


One way of this will be to keep a flag in the user table and set it online when a user logs in and you can implement the interface that reflects this flag.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜