SessionLoginThrottle
Throttles login attempts by imposing a linearly increasing delay after each failed attempt
Helps prevent dictionary and brute-force attacks against user accounts.
Session The delay is calculated as Expand all Collapse all API reference Configuration is managed in the admin at Modules > Configure > Session After If The module hooks The hook checks whether the login name (and optionally IP) has exceeded the allowed
attempt frequency. If another module has already disallowed the login, this module
does nothing (it only acts when On install, the module creates the Expired rows ( When a login is blocked: The Session If you need custom throttling logic, hook A custom exception thrown when a non-ProcessLogin context triggers a throttle block. This exception extends Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the In addition to the methods and properties above, SessionSession::allowLoginAttempt
hook. On every login attempt, it checks a database table (session_login_throttle)
for previous failed attempts by the same username (and optionally IP address). If a
retry arrives too soon, the login is blocked and an error is shown.(attempts - 1) × seconds, capped at maxSeconds. After
maxSeconds of inactivity, the attempt counter resets.// The module is installed and configured in the admin.
// Once configured, it protects logins automatically — no API calls needed.
// Check if a specific name is currently blocked (unusual, but available):
$module = $modules->get('Session$module = $modules->get('SessionProperty Type Default Description secondsint5Base wait time in seconds per failed attempt. Multiplied by (attempts - 1).maxSecondsint60Maximum wait time cap in seconds. Also resets the attempt counter after this many idle seconds. checkIPbool|intfalseThrottle by IP address in addition to username. Recommended unless users share IPs. logFailsbool|intfalseWrite a log entry to login-throttle when a name/IP is blocked.Wait time calculation
N failed attempts, the required wait before the next attempt is:wait = min((N - 1) × seconds, maxSeconds)Attempt Wait (with seconds=5, maxSeconds=60)1st 0 seconds (no wait) 2nd 5 seconds 3rd 10 seconds 4th 15 seconds … … 13th 60 seconds (capped) maxSeconds have elapsed since the last attempt, the counter resets and the next
attempt is treated as the first.Hook into Session
Session::allowLoginAttempt in its init() method. This hook fires
before a user object is loaded — the module only needs the login name, not the user.// In Session$event->return is true).Database table
session_login_throttle table:Column Type Description namevarchar(128)Username or IP address (primary key) attemptsint(10) unsignedNumber of consecutive failed attempts last_attemptint(10) unsignedUnix timestamp of last attempt last_attempt older than maxSeconds) are deleted on each check.Error behavior
ProcessLogin): An error notice is shown to the user.Session is thrown
to ensure the error cannot be missed.Request caching
allowLogin() method caches results per name for the lifetime of the request.
This prevents multiple hook invocations from double-counting an attempt within a
single request.Session Hook Purpose Session::allowLoginAttemptThe module hooks after this to check attempt frequency Session::allowLoginAttempt yourself.
Sessionfalse, this module does nothing.// Custom IP blocklist, runs before Sessiontry {
$session->login('username', 'password');
} catch(SessionWireException.$config->demo is enabled (prevents interference
with the demo site).singular: true — no more than one instance can be loaded.autoload is conditional: the module only loads when $_POST is not empty
(a form submission is in progress).name (primary key), so lookups are fast even
with many tracked usernames.login(), logout(),
and the complete list of hookable methods.wire/modules/Session/SessionAPI reference: methods, properties
Session class also inherits all the methods and properties of: WireData and Wire.Properties
Name Return Summary Session int bool Session int bool Session int Session int Additional methods and properties
API reference based on ProcessWire core version 3.0.269