PHP code example of freedomsex / self-signed-token

1. Go to this page and download the library: Download freedomsex/self-signed-token library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

freedomsex / self-signed-token example snippets


$signedToken = new SelfSignedToken();
$token = $signedToken->create(); // that's all

$id = $signedToken->generateId();
// OR
$id = $signedToken->generateId($prefix);

$token = $signedToken->create($id);
$token = $signedToken->create('anyrandomstring');

$signedToken = new SelfSignedToken();
// OR
$signedToken = new SelfSignedToken($ttl);
// OR
$signedToken->setTtl($time);

$token = $signedToken->create();
$created = $signedToken->created(); // get creation time
// OR set any time
$token = $signedToken->create($id, $created);
$token = $signedToken->create(null, $created);

$signedToken = new SelfSignedToken($ttl);
// OR 
$signedToken = new SelfSignedToken($ttl, $secret);
$token = $signedToken->create();

$signedToken->valid($token);
// OR
$signedToken->valid($token, $ignoreSign);
// OR
$signedToken->valid($token, $ignoreSign, $ignoreExpires);