Skip to main content
Version: Fegg 5.x

RateLimit::isLimited

Check whether the next attempt would be refused

Description​

public bool RateLimit::isLimited( string $key )

Returns true when $key already has $max attempts in the window. Nothing is recorded.

Use it to show a message before the visitor fills in a form. To enforce the limit, use attempt(): two requests can both see isLimited() return false.

Arguments​

NameData typeDefaultRemarks
$keystringWho is counted

Example​

Controller
use Fegg\Tool\RateLimit;

$this->page['limited'] = (new RateLimit('contact', 5, 3600))->isLimited((string) $_SERVER['REMOTE_ADDR']);
$this->displayPage('contact/index');