php - Keeping track of user's views on pages -


this question has answer here:

i've built simple forum made of categories, topics, , posts. keep track of how many unique views each post has received. not suspect daily traffic each post posts designated specific users. if had estimate, 500 1000 views (as maximum) per day each post; realistically 200 - 300 views.

what thinking of doing:

all posts loaded through php script named topic.php. @ beginning of script include code first checks if cookie exists, , if not check database user's ip , post @ hand. if database found user's ip , post-id, create cookie let script know on next page load no bother database query.

question:

  • is storing user's ip , post-id (perhaps along timestamp) proper way keep track of unique post views?
  • is method i've described above considered "best practice" or efficient standards?

thanks, evan

i'm no expert means can't answer whether efficient way, using user's ip address may not great way users have dynamic ip address, ip change frequently. if you're counting on ip being same every time, won't able use method.

will users registering use forum? if so, simple session cookie when login should enough uniqueness.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

python - malformed header from script index.py Bad header -