https://github.com/emartech/session-validator-client-php
PHP client for Emarsys session validator service
https://github.com/emartech/session-validator-client-php
Last synced: about 1 year ago
JSON representation
PHP client for Emarsys session validator service
- Host: GitHub
- URL: https://github.com/emartech/session-validator-client-php
- Owner: emartech
- License: mit
- Created: 2018-08-02T07:48:07.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2025-03-25T15:48:35.000Z (over 1 year ago)
- Last Synced: 2025-07-06T00:01:48.139Z (about 1 year ago)
- Language: PHP
- Size: 39.1 KB
- Stars: 0
- Watchers: 18
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Session Validator Client PHP
PHP client for Emarsys session validator service
## Install
```bash
composer require emartech/session-validator-client
```
## Usage
### Create client
Escher example:
```php
$client = Client::create('https://session-validator.gservice.emarsys.net', 'escher_key', 'escher_secret');
```
mTLS example:
```php
$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` | |
```php
var_dump($client->isValid('msid'));
```
```php
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.
```php
var_dump($client->filterInvalid(['msid1', 'msid2']));
```
### Caching results
```php
$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`.
```php
const sessionData = $client->getSessionData('session-data-token');
```
### Logging
To enable logging, add a PSR-3 compatible logger to the client
```php
use Monolog\Logger;
$client->setLogger(new Logger('name'));
```
### Local development
```bash
make install
make test
make style
```