-1

My website has a like button that is similar to facebook like button. When user click it, the count increases. On clicking again, count decreases. Same as we click like and unlike in facebook. So only logged in users can hit like button

But the problem is no one is hitting the like button. I think it is due registering. My website is new. So visitors may not be interested in clicking like button after registering (even though i have included facebook login)

My question is can i use ip address for like button working. So visitors can click like button even without registering. I will write a php script that will capture ip address. So when clicked ip address is stored instead of username. Again clicking it will make it unlike.

I hope the idea is clear. Can i use this technique?? Because i heard ip address changes often.

this is my website www.huzup.com Its and online directory and search engine where users can submit their website, find similar sites, rate each site by clicking a like button as described above

Gijo Varghese
  • 11,264
  • 22
  • 73
  • 122
  • Its very possible to do, but you are correct, alot of ISP issue dynamic public ip's to there clients, some even issue NAT'd ip to there clients. So there will be cases where a user has clicked like, comes back to the page a few days later and will be able to click like again. In other words your "likes" will be inaccurate. – Rob Apr 25 '14 at 06:25
  • 1
    IP addresses can change even during a single session, maybe try using cookies instead – tylerlindell Apr 25 '14 at 06:26
  • @Rob thanks a lot. Will cookies never expire?? The only thing i am using this may temporarily. How is my site and its idea? Any idea it will become hit?? in future i will make it so that only registered users can like. I don't know why. no visitors :( – Gijo Varghese Apr 25 '14 at 06:45
  • Cookies will be more reliable, but can be removed, or expire. So still not the perfect solution here. Why not just stick the Facebook "like", I see its on your page already. Users will not need to auth, and it will be unique. – Rob Apr 25 '14 at 06:59
  • @Rob but the websites must be sorted according to the likes count. Can i get the like count from facebook? – Gijo Varghese Apr 25 '14 at 07:01
  • O sorry i misunderstood, you probably could, but it would be a mission. I think you going to need to use cookies then to see if they have click like. Or when they click the like button ask them for the email address or something (easy to get around it, but atleast its something) – Rob Apr 25 '14 at 07:04
  • Have a look at this link http://stackoverflow.com/questions/4001973/tracking-unique-visitors-only – Rob Apr 25 '14 at 07:08
  • @Rob sorry i didn't get what you mean. Can i get the numbers of users who hit like button? – Gijo Varghese Apr 25 '14 at 11:09

2 Answers2

0

You should go with Cookies if you want to keep a track of the browsers.

nazim
  • 1,439
  • 2
  • 16
  • 26
  • thanks a lot. Will cookies never expire?? The only thing i am using this may temporarily. How is my site and its idea? Any idea it will become hit?? in future i will make it so that only registered users can like. I don't know why. no visitors :( – Gijo Varghese Apr 25 '14 at 07:01
  • You can set the period for cookies to expire. http://www.php.net/manual/en/function.setcookie.php – nazim Apr 25 '14 at 07:04
0

$ip = $_SERVER["REMOTE_ADDR"];