Welcome!
Login
Contents
Page Views Counter Per Session/Cookies
Article Rating
Current Rating
Total Votes
10
Your Rating
Extremely Helpful
Very Helpful
Helpful
Not Helpful
Waste of Time
Page Views Counter Per Session/Cookies
By feha
Page Views Counter Per Session/Cookies
<--Chapter=Page Views Counter Per Session/Cookies--> Many times there is a need to know how many times one page was viewed ... There is a page views counter ... But if same visitor reloads page it adds counts ... A bit better solution is to count per session. Here is TIP how to DO is with in Code Chagrge Studio ... Use it in an event Before Show (PAGE) And customise it to Your DB table ... //Custom Code @491-9F15008E // ------------------------- 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); } // ------------------------- //End Custom Code It can be modified to use Cookies instead of Sessions ... Just Replace as: CCGetCookie("UserIP","") CCSetCookie("UserIP", $ip); Author: Femi Hasani [www.vision.to]
This site was generated with
CodeCharge