Who's Online Application
page 2 of 7
by Alex Campbell
Feedback
Average Rating: 
Views (Total / Last 10 Days): 56151/ 172

Data Model

Data Model

For the purposes of the application, we are going to keep the user's details in an SQL Server database, along with the URL and timestamp of every page they visit.  Thus we have two database tables:

/* tables for holding the details of each user and their clickstream */
    CREATE TABLE [dbo].[tbl_OnlineUsers] (
    [IP_Address] [varchar] (15) NOT NULL, /* max is 255.255.255.255 ie 15 chars */
    [Session_ID] [varchar] (50) NOT NULL,
    [User_Agent] [varchar] (250) NULL,
    [Referer] [varchar] (250) NULL, /* yes, it is spelt incorrectly in the HTTP standard */
    [TimeStamp] [datetime] NOT NULL
    )
    GO

    CREATE TABLE [dbo].[tbl_OnlineUsers_VisitedURLs] (
    [URL] [varchar] (250) NOT NULL, /* we don't keep querystrings for security reasons, so 250 chars should be enough*/
    [Session_ID] [varchar] (50) NOT NULL,
    [Timestamp] [datetime] NOT NULL
    )

And 7 stored procedures to manage them, but I won't describe them here as they are detailed in the DDL file here.


View Entire Article

User Comments

Title: Session.SessionID.ToString());   
Name: Spyros
Date: 10/26/2011 3:19:28 PM
Comment:
Seems not to work on asp.net 3.5 .
In global asa Session.SessionID.ToString()); is null.
Any idea ?
Title: Download links are broken   
Name: Linu
Date: 12/21/2009 1:33:33 AM
Comment:
The download link is broken, please fix it!
Title: I think it is possible to overcome the database hit issue   
Name: Yasser
Date: 11/16/2009 12:56:51 PM
Comment:
You're right, there is no point in doing a trip to the database on every request. As information about active users is useless once their session expires, I think it is a silly idea to store this information in the database (unless some kind of user online history needs to be stored). One alternative is to keep all logged in users in memory and do an in-memory lookup rather than a database lookup. The cleanup tasks are also performed on the online users collection object in memory.
Title: Bad idea ?!!! are you kidding me   
Name: Vex
Date: 11/9/2008 3:51:31 PM
Comment:
When is the last time you checked out myspace.com and facebook.com . People want to know which ones of their friends are online and they want to chat to them. that's one of the main interactive features of any social network website.
Title: Why this could be useful   
Name: Sharky
Date: 1/19/2008 11:31:05 PM
Comment:
one use is to see who is online to engage in an online chat. I think MySpace does this. There is a built in ASP.Net 2.0 function that shows you the number of users online but no built in query to show you who they are.
Title: Code names mixed   
Name: Frank
Date: 9/17/2007 8:16:37 AM
Comment:
Just an FYI. The links for the zip files are backwards. CS is under VB and vice versa.

Great info tho, just what my customer wants. Same as David Allen said, small site (100 users tops) and the admin's want to be able to see who's logging in as well as who's sharing their logins.

I had no idea how this would be done and you've knocked off a lot of time figuring it out on my own.

Thanks,
Frank
Title: Why this is a good idea   
Name: David Allen
Date: 8/2/2005 10:43:21 PM
Comment:
Your concerns about performance impact are legitimate; I share them.
But in enterprise applications (not high-volume, public applications), where users are known and from a limited pool of users, and you support them, then this can be very handy.
Respectfully,
davidkallen at yahoo dot com (email munged to prevent spam)






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2014 ASPAlliance.com  |  Page Processed at 8/27/2014 11:04:51 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search