2017 © Pedro Peláez
 

library token

image

jsnlib/token

  • Friday, March 30, 2018
  • by fdjkgh580
  • Repository
  • 1 Watchers
  • 0 Stars
  • 22 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

jsnlib-token

簡單快速的產生 token 並驗證是否過期失效, (*1)

require_once '../vendor/autoload.php';
$tk = new \Jsnlib\Token;

// 1. 加入使用鑰匙
$tk->key(uniqid('test132'));

// 2. 取得 Token 過期日
$expiry = $tk->expriy_date("Y-m-d H:i:s", "now", +1, "day");

// 3. 綁定編號,並加入過期日,可產生 Token 
$token = $tk->create('ABC', $expiry);
/**
 * Jsnlib\Ao 輸出格式如
 * value => '42d398f2ecef48da5b4dab7e63c3323a8894048357ce8ba319dbec7ea847cb99'
 * expiry => '2017-08-15'
 */
// echo $token;

/**
 * 若要 JSON 格式如
 * array ( 'value' => '1a94b598b4067998b601221a47068cc31ac8fd6c3748abffec3e9046cd164cc5', 'expiry' => '2017-08-09 10:16:41', )
 */
// echo ($tk->json($token));

// 4. 檢查是否已經過期
if ( ! $is_expiry = $tk->is_expiry($token->expiry))
{
    echo "未過期";
}
else
{
    echo "已過期";
}

The Versions

30/03 2018

dev-master

9999999-dev https://github.com/fdjkgh580/token

  Sources   Download

MIT

The Requires

 

30/03 2018

1.0.1

1.0.1.0 https://github.com/fdjkgh580/token

  Sources   Download

MIT

The Requires

 

08/08 2017

1.0.0

1.0.0.0 https://github.com/fdjkgh580/token

  Sources   Download

MIT

The Requires