PHP code example of horde / token
1. Go to this page and download the library: Download horde/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/ */
horde / token example snippets
$conf['token']['driver'] = 'File';
$conf['token']['params']['path'] = '/path/to/token/storage';
$conf['token']['driver'] = 'Mongo';
$conf['token']['params']['mongo'] = array(
'hostspec' => 'mongodb://localhost:27017',
'database' => 'horde',
'collection' => 'tokens'
);
// Basic token settings
$conf['urls']['token_lifetime'] = 30; // Token lifetime in seconds
$conf['urls']['hmac_lifetime'] = 30; // HMAC validation lifetime
// Storage driver configuration
$conf['token']['driver'] = 'Sql'; // or 'File' or 'Mongo'
$conf['token']['params'] = array(
// Driver-specific parameters
);
// Get token instance
$token = $injector->getInstance('Horde_Token');
// Generate a new token
$tokenId = $token->get('token_address');
// Validate a token
$valid = $token->isValid($tokenId, 'token_address');
// Delete a token
$token->delete('token_address', $tokenId);