setono / client
PHP abstraction for identifying a browser client
Fund package maintenance!
Setono
Installs: 5 280
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=8.1
Requires (Dev)
- infection/infection: ^0.27.10
- phpunit/phpunit: ^9.6.13
- psalm/plugin-phpunit: ^0.18.4
- ramsey/uuid: ^4.7
- setono/code-quality-pack: ^2.7
- symfony/uid: ^6.4 || ^7.0
This package is auto-updated.
Last update: 2024-11-07 10:37:46 UTC
README
Installation
composer require setono/client
If you don't use your own client id generation strategy, you should also install either the symfony/uid or the ramsey/uuid package:
# If you want to use symfony/uid composer require symfony/uid # If you want to use ramsey/uuid composer require ramsey/uuid
Usage
use Setono\Client\Client; // initialization with a generated id and an empty metadata object $client = new Client(); // initialization with your own id and existing metadata $client = new Client('my-client-id', ['foo' => 'bar']); // get the client id $id = $client->id; // set metadata $client->metadata->set('foo', 'bar'); // set metadata that expires in 1 hour $client->metadata->set('foo', 'bar', 3600); // get metadata $client->metadata->get('foo'); // remove metadata $client->metadata->remove('foo');
There's also a Cookie
class which can be used to store the client id in a cookie.