Tracking unique visitors only?

后端 未结 7 1905
猫巷女王i
猫巷女王i 2020-12-03 05:49

Currently I have a file called \"hits.php\" and on any page I want to track page hits I just use

How can I track u

7条回答
  •  一个人的身影
    2020-12-03 06:13

    The simplest method would be cookie checking.

    A better way would be to create an SQL database and assign the IP address as the primary key. Then whenever a user visits, you would insert that IP into the database.

    1. Create a function included on all pages that checks for $_SESSION['logged'] which you can assign whatever 'flag' you want.
    2. If $_SESSION['logged'] returns 'false' then insert their IP address into the MySQL database.
    3. Set $_SESSION['logged'] to 'true' so you don't waste resources logging the IP multiple times.

    Note: When creating the MySQL table, assign the IP address' field as the key.

    
    

提交回复
热议问题