Count page access count

Source: Internet
Author: User
Tags servervariables

To count the number of pages, we must insert the user's page from which to the database, and then calculate each page through the stored procedure.

Number of accesses. I only say how to insert the Source Page and target page to the database.

Generally, the Source Page is page. Request. servervariables ["http_referer"]. The target page

For page. Request. servervariables ["script_name"],
However, in special cases, the Source Page cannot be obtained through the previous method.

In either case, you cannot use the following method:
1. When the target page is a pop page, Firefox allows access to the Source Page

Page. Request. servervariables ["http_referer"], but ie cannot.
Then how do we get the Source Page? we store the target page of the previous page through cookies.

The page is saved as the source page of this page.
If (page. Request. servervariables ["http_referer"] = NULL), retrieve the target page of the previous page. Otherwise

Take page. Request. servervariables ["http_referer"].

2. When you press F5 or right-click to refresh, we should avoid inserting data into the database. We need to determine whether the user has performed this operation.
In fact, it is to judge whether the user refreshes. Of course, you can set a flag in JS to determine, but this requires every page to be written.
I chose to judge on the server side, but there is a small problem.
I checked whether the Source Page and target page that I clicked last time were the same as the next page. If they were the same, I thought they were refreshed.
The Code is as follows:

 

Code
1 If (request. Cookies ["IPS"] ["lastoriginalpagepath"]! = NULL & request. Cookies ["IPS"]
2
3 ["lastdestinationpagepath"]! = NULL)
4 {
5 If (request. Cookies ["IPS"] ["lastoriginalpagepath"]. tostring ()! =
6
7request. Cookies ["IPS"] ["lastdestinationpagepath"]. tostring ())
8 {
9 If (page. Request. servervariables ["http_referer"]! =
10
11 null & page. Request. servervariables ["script_name"]! = NULL)
12 {
13 if (request. Cookies ["IPS"] ["lastoriginalpagepath"]. tostring () =
14
15page. Request. servervariables ["http_referer"]. tostring () & request. Cookies ["IPS"]
16
17 ["lastdestinationpagepath"]. tostring () =
18
19page. Request. servervariables ["script_name"]. tostring ())
20 {
21 bolisrefresh = true;
22}
23
24}
25}
26}
27response. Cookies ["IPS"] ["lastoriginalpagepath"] = page. Request. servervariables ["http_referer"];
28 response. Cookies ["IPS"] ["lastdestinationpagepath"] =
29
30page. Request. servervariables ["script_name"];
31

However, the disadvantage is that this method cannot be determined when the clicked page is still on this page.
To be perfect, you can only process such page Js.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.