How can I read pageviews?

How to count page views so that when you turn on and refresh the page, the counter does not consider this a new view?

+3
source share
2 answers

1-declare a session for each user

2- declare an application variable for the visited page

and after starting the session

check if the page was visited as follows:

on the user login page or on the main page:

Session["pageVisited"] = false;

when the user visits the page, writes the code:

if(SESSION["pageVisited"] == false)
{
   APPLICATION["Page1Visited"] = Convert.Toint32(APPLICATION["Page1Visited"]) + 1;
   SESSION["pageVisited"] = true;
}
+6
source
+5
source

Source: https://habr.com/ru/post/1726778/


All Articles