public function token() {
$jwt = new JWT();
$JwtSecretKey = 'YourSecretKey';
$data = array(
'id' => 1,
'email' => 'test@mail.com',
'role' => 'admin'
);
$token = $jwt->encode($data, $JwtSecretKey, 'HS256');
echo $token;
}
public function decode_token() {
$token = $this->uri->segment(3);
$jwt = new JWT();
$JwtSecretKey = 'YourSecretKey';
$decoded_token = $jwt->decode($token, $JwtSecretKey, 'HS256');
// std_object
print_r($decoded_token);
// json
$tokenJSON = $jwt->jsonEncode($decoded_token);
echo $tokenJSON;
}