How to show whether a user is Online
It's simple. If you want to show the list of currently online users, simply use the holy "APPLICATION" object provided by Microsoft developers to bail you out. Here I will describe a logic to show how many users are online since last X minutes.
Remember those old school concepts from networking. Evrey machine sends a message "I AM ALIVE" to server so that server can know which node is active. We will use the same funda here. You must be knowing that application variables are site specific and common for all users. So whatever you store in an application variable, will be accessible to all users using that application. You can use following syntax to store anything to Application Variables...
application("<variable>") = <value>
You need to store the User's ID, Name and time it was last updated. So when in your application you check for session/cookie on top of every page, update the application variable (if user is still logged in). And remember that you need to check for existing value against the current user. If the current user is already registered in Application variable, update its last access time or otherwise make a new entry.
You can have data in array format in application variable for this.
When displaying currently logged users, disply only those users who have updated their entry in a specified time period. You can remove other entries to keep your logic optimized.
Try it out. its easy to implement. :)
Wednesday, October 10, 2007
Is He On
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment