PHP code example of machaven / track-attempts

1. Go to this page and download the library: Download machaven/track-attempts library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

machaven / track-attempts example snippets


$config = ['driver' => 'predis', userIdentifier' => $username];
$attempts = (new \Machaven\TrackAttempts\TrackAttempts($config))->getDriver();


>>> $attempts->increment();
=> true

>>> $attempts->getCount();
=> 1

>>> $attempts->isLimitReached();
=> false

>>> $attempts->clear();
=> true

>>> $attempts->getTimeUntilExpired();
=> 188

>>> $attempts->incrementAndCheckLimit();
=> true
>>> $attempts->incrementAndCheckLimit();
=> true
>>> $attempts->incrementAndCheckLimit();
=> true
>>> $attempts->incrementAndCheckLimit();
=> false