Hello my friend,
If I were you, I would store 2 session variables, one containing the logged in time and the other containing the time that they last requested a page. Put the following within the Application_BeginRequest event
Session("Last_Requested_Something") = DateTime.Now
Now within the Session_End event using these 2 variables, you can record the session start date and the date the user last looked at something giving you the approximate duration of their visit to the site.
To prove the events are firing, put this line into the Application_Start event: -
Application("SessionCounter") = 0
And the following into the Session_Start event: -
Dim intSessions as Integer = Integer.Parse(Application("SessionCounter"))
Application("SessionCounter") = (intSessions + 1)
And add the following into the Session_End event: -
Dim intSessions as Integer = Integer.Parse(Application("SessionCounter"))
Application("SessionCounter") = (intSessions + 1)
Then print Application("SessionCounter") on any of your pages. Sessions last 20 minutes by default. Change this in the web.config to see the effects. The following sets the timeout to 1 minute: -
<sessionState timeout="1"/>
Kind regards
Scotty