Skip to content

emartech/session-validator-client-php

Repository files navigation

Session Validator Client PHP

PHP client for Emarsys session validator service

Install

composer require emartech/session-validator-client

Usage

Create 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');

Check Session Validity

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'));

Batch validating multiple MSIDs

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']));

Caching results

$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'));

Fetch session data

getSessionData provides a function to fetch user session data object using a sessionDataToken.

const sessionData = $client->getSessionData('session-data-token');

Logging

To enable logging, add a PSR-3 compatible logger to the client

use Monolog\Logger;

$client->setLogger(new Logger('name'));

Local development

make install
make test
make style

About

PHP client for Emarsys session validator service

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published