nestboxphp / titmouse
User registration and session management with built-in password best-practices.
Installs: 13
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/nestboxphp/titmouse
Requires
- nestboxphp/nestbox: >=v0.0.1
Requires (Dev)
- nestboxphp/nestbox: >=v0.0.1
This package is auto-updated.
Last update: 2025-11-06 19:30:20 UTC
README
A user management interface that can register, login, and logout users while adhering to standard security practices for password handling.
Usage
Titmouse requries Nestbox to function
Settings
| Setting | Description | Default |
|---|---|---|
| usersTable | Defines the table name in which user data is stored. | users |
| userColumn | Defines the column name which identifies the unique ID for each user. | username |
| nameLength | Defines the max number of characters in a user name. | 64 |
| mailColumn | Defines the column name which stores the user email. | email |
| hashColumn | Defines the column name which stores the hashword of a user. | hashword |
| sessionKey | Defines the $_SESSION key which is used to store and access user data. |
user_data |
Methods
Register User
Registers a user and associates a new hash for logging in.
$tm->register_user(array $userData, string $password): bool
$userData: an array containing key => value pairs where the key is any given column name in the user table and the value is the data to be stored in that column.$password: the plain-text password the user will use to log in with.
Select User
Selects a user from the users table.
$tm->select_user(string $user): array
$user: the string value of the user id being selected
Login User
Logs in a user, and will load the user data into the $_SESSION variable. For additional security, it will
automatically rehash a given password if a newer and/or better hashing algorithm has been identified and is available.
$tm->login_user(string $user, string $password, bool $loadToSession = true): array
$user: string value of the username to be logged in$password: plain-text string value of the user's password$loadToSession: boolean determining if the user data will be loaded into the$_SESSIONvariable using thesessionKeysetting's value
Update User
Updates a user in the users data table with the given data.
$tm->update_user(string $user, array $userData): int
$user: string value of the username to be updated in the user table$userData: an array of key => value pairs where the key is the name of the column where the value will be stored
Load User Session
Load an array of data into the $_SESSION variable within the sessionKey key.
$tm->load_user_session(array $userData): void
$user: array of whatever key => value pairs to be stored in the$_SESSIONvariable under thesessionKeykey
Logout User
Clears out all $_SESSION user data under the sessionKey key while leaving any other remaining $_SESSION data
intact
$tm->logout_user(): void
Verify Email
work in progress
$tm->verify_email(): bool
Change Password
Changes the current password of $user to a new hash of $newPassword. Returns true if successful, otherwise false.
$tm->change_password(string $user, string $newPassword): bool
$user: string value of the user for which the password is being updated$newPassword: plain-text string value of the new password to be used