How do I count unique visitors to my site?

前端 未结 5 648
粉色の甜心
粉色の甜心 2020-11-27 14:09

I am making a visitor counting system for user posts to show the most viewed posts on homepage. I have a visitor counting system now but all it registers a view at every pag

5条回答
  •  隐瞒了意图╮
    2020-11-27 14:30

    for finding out that user is new or old , Get user IP .

    create a table for IPs and their visits timestamp .

    check IF IP does not exists OR time()-saved_timestamp > 60*60*24 (for 1 day) ,edit the IP's timestamp to time() (means now) and increase your view one .

    else , do nothing .

    FYI : user IP is stored in $_SERVER['REMOTE_ADDR'] variable

提交回复
热议问题