Determing Power Users

I’m using the standard SQL Membership provider to manage my users and I’m looking for the best approach to determine a ‘power user’, or a user who uses the site much more than others. I can’t seem to find anywhere in the SQL user database where login counts are maintained so this is useless.

Since most visitors of my site will likely check the ‘remember me’ checkbox when logging in, they probably won’t login every time they access the application. So I don’t believe that incrementing some counter each time a user logs-in is the best approach.

I’m thinking that I’d need to somehow count user sessions instead, but what would be the approach to make this happen?

The “remember me” feature does not replace a login (or generation of a session) it simply relies on the browser to do it instead of the user.

So it sounds like the SessionID is the best mechanism to track repeat visitors because even if ‘LastLogin’ was updated in the database, it wouldn’t be very useful in the short-term.

Does this mean that the only solution would be to compare each user’s current SessionID against their previous SessionID which we’d have to store somewhere in the database? If they’re different we’d update the SessionID and increment a counter.

But what bothers me is that it seems I’d have to perform this check on every page since a user could theoretically re-enter the application on any page following an expired session.

I could use my ‘BasePage’ class which all other pages inherit from to make this check, but doing a DB query for every user and every page request seems like a whole lot of DB access. Is there any more efficient way?

Sessions are quite unreliable but if you go that route you could do something at HttpApplication.SessionStart event.

I’ll note this problem gets real non-trivial real fast, especially if you care about accuracy. The approach I would take would be something more like web stats where I would use a HttpModule to track requests / actions by user ID and then aggregate off that. This data will get pretty big pretty fast for an active site.

100% accuracy isn’t entirely necessary as I’m only needing approximations right now. SessionStart is a much better idea than logging things on every page, but an HttpModule may be just as resource intensive if I’m logging each user action. I’ll have to look into HttpModules to see what kind of stuff I can track on a per-user basis.

Thanks again!

One trick – HttpModules and everything else has access to the Request.Items collection. So you can stuff command objects into that and then handle the write asynchonously after you’ve sent the page down the wire.