Skip to content

Solo TokensHand out the secret. Keep only the hash.

Tokens for reset links, invitations and sessions. Random secrets go to the user, only their hashes are stored, in Redis or in memory.

Solo Tokens
php
use Solo\Tokens\RedisTokenStore;

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$resets = new RedisTokenStore($redis, 'app:password-reset:');

$secret = $resets->issue($email, ttlSeconds: 3600);
$mailer->send($email, "https://example.com/reset?token={$secret}");

// Later, when the link comes back:
$token = $resets->consume($submittedToken) ?? throw new InvalidResetLink();
$users->setPassword($token->subject, $newPassword);

The store keeps only the hash of $secret. consume() returns the token once and null ever after. Read the getting-started guide for sessions, revoking and tokens kept in your own tables.

Installation ​

PHP 8.3+ is required. Composer installs psr/clock ^1.0 with the package. RedisTokenStore needs the redis extension and Redis 5.0 or later.

sh
composer require solophp/tokens

Continue with the getting-started guide.

MIT licensed.