开发者

implemenatations of product hit counters

开发者 https://www.devze.com 2022-12-14 05:27 出处:网络
I have been scouring for a while about this one but haven\'t seen a decent tutorial. the problem is I want to create a hit counter everytime a product\'s page is viewed

I have been scouring for a while about this one but haven't seen a decent tutorial.

the problem is I want to create a hit counter everytime a product's page is viewed

I am using a PHP MVC framework and these are what I want to do

  1. update a database counter everytime a page is visited
  2. check if a the product is repeatedly viewed in the same terminal to a开发者_运维问答void multiple viewing from one user

How will I go about implementing this?


Depending on how accurate you want it to be...

  • If accuracy is not a major concern, save a cookie or a session value to the client. Check this before incrementing counter. This is simplest to implement.
  • Create a table in your db which keeps track of what IP address (or other metric) has viewed what product. This would give a more accurate reading I think, but is considerably more complex.
0

精彩评论

暂无评论...
验证码 换一张
取 消