PHP client for Emarsys session validator service
composer require emartech/session-validator-client
Escher example:
$client = Client::create('https://session-validator.gservice.emarsys.net', 'escher_key', 'escher_secret');
mTLS example:
$client = Client::create('http://session-validator-web.security');
isValid
provides a function to validate user session using either a msId
or a sessionDataToken
.
Name | Type | Throws | Description |
---|---|---|---|
msId |
string |
- | Deprecated and will be removed in the future |
sessionDataToken |
string |
SessionDataError |
var_dump($client->isValid('msid'));
var_dump($client->isValid('session-data-token'));
Returns an array of the invalid MSIDs.
Warning: The batch validation is deprecated and will be removed in the future.
var_dump($client->filterInvalid(['msid1', 'msid2']));
$client = Client::create('https://session-validator.gservice.emarsys.net', 'escher_key', 'escher_secret');
$cachedClient = CachedClient::create($client);
var_dump($cachedClient->isValid('msid')); // OR
var_dump($cachedClient->isValid('session-data-token'));
getSessionData
provides a function to fetch user session data object using a sessionDataToken
.
const sessionData = $client->getSessionData('session-data-token');
To enable logging, add a PSR-3 compatible logger to the client
use Monolog\Logger;
$client->setLogger(new Logger('name'));
make install
make test
make style