I have an asp.net web app that has Session state stored in sql server. I need to keep track of the time spent by a user on each page. How can i do that using cookies?
If you can get away with tracking time for all users collectively rather than individual users, I would install Google Analytics.
Couldn't you use a cookie to store the time when the user navigated to the page and then when they navigate to another page calculate the time spent on the previous page, enter that into the database or something and then repeat the process?
Tracking user time across a site isn't ideally done in the cookies, which are more for providng things back to the user.
That said, you'd need to store the intermediate data in the cookie if you're going to store the true 'time per page' per user rather than faking it at the server by counting the gap between page requests per session. You could do this by setting the load time at the page load, then comparing that to the current time in the onUnload event hander. Save that to the cookie and it should be available to the server in the request body of the next page it sends.
Is it possible to track only those who have been on the site for a certain amount of time and cookie them?