Skip to content
/ client Public

PHP abstraction for identifying a browser client

License

Notifications You must be signed in to change notification settings

Setono/client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Mar 11, 2025
a20fb98 · Mar 11, 2025

History

29 Commits
Mar 12, 2024
May 7, 2024
May 7, 2024
Mar 12, 2024
Mar 12, 2024
Mar 12, 2024
Mar 12, 2024
May 7, 2024
Mar 12, 2024
Mar 11, 2025
Mar 12, 2024
May 7, 2024
Mar 12, 2024
May 7, 2024
Mar 12, 2024

Repository files navigation

PHP abstraction for identifying a browser client

Latest Version Software License Build Status Code Coverage Mutation testing

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.