'biji-php', 'iat' => time(), 'exp' => time() + self::$expire, 'userId' => $userId, 'username' => $username ]; return JWT::encode($payload, self::$secret, 'HS256'); } public static function decode($token) { self::init(); try { $decoded = JWT::decode($token, new Key(self::$secret, 'HS256')); return (array)$decoded; } catch (\Exception $e) { return null; } } }