Hi, i am in the middle of developing a website, and i would like to add a function to my site whereby a member can see how many times their profile page has been viewed, similar to the way YouTube displays the amount of hits a video has.
I have a few questions which i hope you can help me with:
A - who does the YouTube counter work OR what is the best way to build these counters... are they (1) - IP based, (2) - Cookie based OR (3) - another method
B - does the page make a database update each time a unique user lands on a video page
C - how often is the number updated... for instance, if i view a video on youtube on several different devices all connected to different networks, the number does not update immediately... so how does it work
Thanks in advance to anyone who can offer any help here
this one is a bit too vague, you can use ip, cookies, sessions, or if everyone must be logged in to use the site usernames would be best.
here's the problem, ip's change if i use several devices or locations i'll have different ip's each time, and some people use dial up and always get new ips. cookies are good too but can be deleted by the end user, and still if i login from 2 devices it will count me twice, sessions also have the same problem if i use several devices then i'll have several sessions, but username never changes - no matter where i login from i'll be using the same username - but ofcourse i may have several usernames.
so it's really hard, you'd probably have to use unique ips in a 24 hour period along with cookies - so first check for a cookie, if no cookie then they are unique or just logging in again from a second device, if the same ip returns then you know they were already counted, so you'd have to place cookies on their device and record ips on your server and compare the two - so something like...
i.e. check if the cookie is missing and that the ip has not been logged yet,
and only if both checks pass they are unique and in that case you want to increment the counter and set a cookie and log the ip.
it all depends on how unique you want the visitor to be, you could even keep the ip log permanently if you only want to count unique ips, but you 'd have to dump it every month or few months so it does not get too big