AKHAN
AKHAN

Reputation: 23

Is there any way to prevent people from changing ip?

I have some problem to solve. I created a website. Website's member has their(A) own page(like blog) and if someone stays in their(A) page for more than a minute, they(A) can earn some points. And by this point they can buy stuff. So radically members(A) should advertise their(A) page, but some members tries to just earn the points using negative ways. Like changing IP and keep visiting their own page.

This is the current way that I'm using

  1. I made the website to check the ip and store it in the database after one minute.
  2. Then I made it to compare ips each time page is visited.
  3. If it has passed 24 hours since last visit, I allowed members to gain point again
  4. But some people figured out this and keep changing their IP and visiting their own page.

  5. Further ways I thought about it was using cookie.

  6. But the thing is that when using cookie, cookie will be set immediately when the page is visited.
  7. So if visitor visited the page for a 30 sec, the points can be earned after visitor visited again for a minute anytime, but using cookie this doesn't work..

So what i want to ask is,

Is there a way to set cookie after a minute when visitor visited site? If not, are there any brilliant way to prevent people from changing their IP?

Upvotes: 2

Views: 170

Answers (1)

Palantir
Palantir

Reputation: 24182

You can't control user's IP, so you will need to track them.

You set a cookie immediately at visit, and in the cookie you can store the date and time of the visit. Each time the user visits your site, read the cookie and check if it contains a time before a minute, then credit the site. Then you can set something else in this cookie, to flag that this user has already received credit. Or, even better, use $_SESSION to store the same things, as a SESSION object will expire if the user stays idle for some time. The SESSION relies usually on cookies anyway (so the next part of the message still holds true).

Now, what if a user deletes his cookie? You have the same problem.

So you should probably resort to some more obscure way to tracking your users. Possibilities: browser fingerprinting (server side), flash cookies, html5 local storage (client side). A user could use multiple browsers, but there are only so many one can install in one computer. You can research those terms and you will find plenty of material. You can also mix those techniques, and add the IP check on top of them... But it will require some develompen time...

Upvotes: 1

Related Questions