Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i work out time spent on site when logged in

Status
Not open for further replies.

oddball

Technical User
Mar 17, 2000
64
0
0
GB
How can i work out the duration of a Forms Authenticated User on a website so that a monthly total can be kept in the database.
 
Store the sytem time when the user logs in.
Then when the user logs out and subtract the difference. Put that value into a table to keep track of it.

You would also want to put some code in your global.asax under the Session_End sub so you can store that time in case the user doesn't log out and is timed out instead. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Thanks Zarcom,

but how would i deal with users that simply close the browser instead of logging out. I would still like to register their Logout Time.

Does closing the browser Abandon the Session for that user or does the session persist untill it times out?

cheers,

si
 
oddball
closing the browser will not abandon the session.
so
1. put some client side script into all pages so that if the browser is closed, it lauches logout.aspx, and then this is rendered, it abandons the session and closes the window.

or

2. when you calculate the average session time, do not include rows where the time is exactly equal to the session timeout, since this will be those where they just closed the browser and did not log out. This approach will give you a figure for the average session time which will of course be skewed, since you don't know some of the data, but it may suffice

Hope this is of some use Mark [openup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top