Page Views Counter Per Session/Cookies
TO view how many times a page was viewed you have a page counter. But if same visitor reloads page it adds counts therefore better solution is to count per session.
Here is TIP how to DO this
Use it in an event Before Show (PAGE)
And customize it to Your DB table ...
Code:
global $InfoDetiails;
// Write your own code here.
global $REMOTE_ADDR;
$check_ip=$REMOTE_ADDR;
if(CCGetParam("news_id","") !="" && CCGetSession("UserIP","") != $check_ip)
{
global $DBddd;
// Write your own code here.
$productSQL="UPDATE webshop_news SET news_viewed=news_viewed+1 WHERE news_id =".CCGetParam("news_id","");
$DBddd->query($productSQL);
$ip=$REMOTE_ADDR;
CCSetSession("UserIP", $ip);
}
It can be modified to use Cookies instead of Sessions ...
Just Replace as: CCGetCookie("UserIP","")
CCSetCookie("UserIP", $ip);
Bookmarks