Click here to Skip to main content
14,695,406 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need a code for finding duration of the visitors login in a website. I didn't use login and logout in my page even though i need to find the duration. Help me for my problem...

Thanks in advance..


Updated 26-Oct-10 6:17am

1 solution

With out login/logout functionality, you will need to somehow identify each of your users and time spend in your site. You won't be able to find exact time as you won't know for sure when they leave the site.

Look into the session object and try to uniquely identify each user. One way to do this would be to listen to the Session Start event and assign unique value to each visitor, perhaps in cookie. Somehow you will need to database this unique value against the the Session ID

string sessionId = HttpContext.Current.Session.SessionID;

Then when the session timed out, compute the total time duration.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900