views:

105

answers:

2

Hi All, I have different modules in my website and need to track how many times the user has visited each tab or module. Currently, I'm using Session variables to store the value and incrementing the counters on each visit on page_load event of the page and loading everything in the database on Session_End event. This seems to work when the user logs off from the application. But it doesn't seem to work when the user closes the browser or redirect to a different site. I thought the Session_End event would fire, no matter what, after the session time out period even if the browser is closed, but it doesn't seem to behave that way. Can anyone suggest a solution to implement this?

Thanks.

A: 

The Session_End event should fire when the session expires, which will be some time after the user's last request to the server.

Remember that it's impossible for the server to know when the browser is closed. (Unless you send an AJAX request in onbeforeunload)

SLaks
A: 

The way I would handle this is to use a custom Profile object. And, pertaining directly to your situation (using Profile vs Session), here is a great article. A little modification, and you can use that code to track page views by which page is being viewed. If you'd like to store this in Profile using a generic list, see my blog post on the subject.

Jim Schubert