\RememberLoginHash
Persists a token associated with a device for users who opted for the "Remember Me" feature when logging in.
By default, logging out will discard all existing tokens for this user
The device ID is a temporary ID associated with the device when the user logged in
and chose to get the login state remembered on this device. When logging out, the ID
is discarded as well.
Synopsis
class RememberLoginHash
extends DataObject
{
- // members
- private static array $db = ;
- private static array $has_one = ;
- private static array $indexes = ;
- private static bool $logout_across_devices = true;
- private static integer $token_expiry_days = 90;
- private static integer $device_expiry_days = 365;
- private static bool $force_single_token = false;
- private $token = NULL;
- // methods
- public void getToken()
- public void setToken()
- protected string getNewDeviceID()
- public string getNewHash()
- public static RememberLoginHash generate()
- public RememberLoginHash renew()
- public static void clear()
Hierarchy
Extends
- DataObject
Members
private
- $db
- $device_expiry_days
—
int
Number of days the device ID will be valid for - $force_single_token
—
bool
If true, user can only use auto login on one device. A user can still login from multiple devices, but previous tokens from other devices will become invalid. - $has_one
- $indexes
- $logout_across_devices
—
bool
Determines if logging out on one device also clears existing login tokens on all other devices owned by the member. -
$token
The token used for the hash - $token_expiry_days
—
int
Number of days the token will be valid for
Methods
protected
- getNewDeviceID() — Randomly generates a new ID used for the device
public
- clear() — Deletes existing tokens for this member if logout_across_devices is true, all tokens are deleted, otherwise only the token for the provided device ID will be removed
- generate() — Generates a new login hash associated with a device The device is assigned a globally unique device ID The returned login hash stores the hashed token in the database, for this device and this member
- getNewHash() — Creates a new random token and hashes it using the member information
- getToken()
- renew() — Generates a new hash for this member but keeps the device ID intact
- setToken()