PHP code example of jusbrasil / tornado-auth-php
1. Go to this page and download the library: Download jusbrasil/tornado-auth-php 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/ */
jusbrasil / tornado-auth-php example snippets
use Jusbrasil\TornadoAuthPhp\TornadoAuthPhpLib;
$auth = new TornadoAuthPhpLib([
'max_age_days' => 2, // [optional] default: (int) 31
'user_cookie' => 'oreo', // [optional] default: (string) user
'secret_key' => 'shhhh', // [
$signedValue = $auth->createSignedValue(['cypher' => 'morpheus']);
// string(80) "eyJjeXBoZXIiOiJtb3JwaGV1cyJ9|1564713616|ca4f8c77f23f120578e742199b12df21f6039ce3"
$signedCookie = $auth->createSignedCookie('oreo', ['cypher' => 'morpheus']);
// string(80) "eyJjeXBoZXIiOiJtb3JwaGV1cyJ9|1564713616|07143659017c55c004108de1e8b3867a8a5a889d"
$decodedSignedValue = $auth->decodeSignedValue('shhhh', 'oreo', $signedValue);
// string(21) "{"cypher":"morpheus"}"
$secureCookie = $auth->getSecureCookie('oreo', $signedValue);
// class stdClass {
// public $cypher => string(8) "morpheus"
// }
$currentUser = $auth->getCurrentUser($signedValue);
// class stdClass {
// public $cypher => string(8) "morpheus"
// }