Counting Page Visits With Javascript And Cookies
I would like to count a users visit to a site within a session and implement certain functionality based on how many pages the user has visited. I would like to perform this solel
Solution 1:
The only reliable way will be to use AJAX and keep track on the server, associated with the user's session ID.
Each load will need to poll the server, then tell the server to increment the counter.
Solution 2:
You could for example, when the user access the page, First check if the cookie exists, if not then set the cookie name and value and also a (token var) as being set so it dosnt increment on page refreshes.
Then one every other page you require the cookie, again check for cookie and then increment it.
I find a easy to use coolkie script Cookies use.
Post a Comment for "Counting Page Visits With Javascript And Cookies"