PHP code example of erwane / cakephp-token

1. Go to this page and download the library: Download erwane/cakephp-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/ */

    

erwane / cakephp-token example snippets


/**
 * Create a token with data and return the id
 * @param  array  $content   an array of custom data
 * @param  string $expire    expire exprimed in '+6 days +2 hours' format
 * @param  int $length Token length
 * @return string            The token id
 */

$myNewTokenId = \Token\Token::generate(array $content, $expire, 8);

// return null (expired or not found) or Token entity
$token = \Token\Token::get($tokenId);

/**
 * Delete token from id or entity
 * 
 * @param \Token\Model\Entity\Token|string $token Token entity or id
 * @return bool True if token was deleted
 */
$result = \Token\Token::delete($token);