SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru pinch's Avatar
    Join Date
    Mar 2005
    Posts
    688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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?

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,332
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    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.
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    SitePoint Guru pinch's Avatar
    Join Date
    Mar 2005
    Posts
    688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    SitePoint Guru pinch's Avatar
    Join Date
    Mar 2005
    Posts
    688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wwb_99 View Post
    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!

  6. #6
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •