jennifer
jennifer

Reputation: 301

can php limit actions based on ip address

i have 2 links that display notifications on my website and its being abused. is there a way to limit the amount of times a user can click the links based on ip address i dont want to block anyone i just want to reduce the amount of times a person can click this link. essentially limiting the requests that can be made

Upvotes: 1

Views: 1703

Answers (3)

Wes
Wes

Reputation: 6585

It is generally not a good idea to rely on the client IP address because of proxies and VPN's that can mask the true value. It would be better to set a cookie and keep track of the clicks in this manner.

Upvotes: 0

Dimitrios Mistriotis
Dimitrios Mistriotis

Reputation: 2788

Definitely, on the pre-set variables (I think $_SERVER array, REMOTE_ADDR) you can see:

The IP address from which the user is viewing the current page.

http://php.net/manual/en/reserved.variables.server.php

Upvotes: 4

Oct
Oct

Reputation: 1525

Yes, implement a simple IP filter using $_SERVER["HTTP_CLIENT_IP"])

confer http://www.php.net/manual/en/language.variables.predefined.php

Upvotes: 0

Related Questions