I've built a simple forum which is made up of categories, topics, and posts. I would like to keep track of how many unique views each post has received. I do not suspect too much daily traffic for each post as posts are designated to specific users. If I had to estimate, I would say 500 to 1000 views (as a maximum) per day for each post; realistically only 200 - 300 views.
What I am thinking of doing:
All posts are loaded through a PHP script named topic.php
. At the beginning of this script I would include some code that first checks if a COOKIE exists, and if not it would check the database for the user's IP and the post at hand. If the database found the user's IP and post-id, I would then create some COOKIE which would let the script know on the next page load no to even bother the database with the query.
Question:
- Is storing the user's IP and post-id (perhaps along with a timestamp) the proper way to keep track of unique post views?
- Is the method I've described above considered to be a "best practice" or even efficient by any standards?
Thanks, Evan