Plugin Author
Bagus
(@contactjavas)
Hi @paxton111 ,
You can use jwt_auth_expire
filter. You can read the more about it in the plugin readme page.
Let me know if that works for you,
Best,
Bagus
/**
* Change the token's expire value.
*
* @param int $expire The default "exp" value in timestamp.
* @param int $issued_at The "iat" value in timestamp.
*
* @return int The "nbf" value.
*/
add_filter(
'jwt_auth_expire',
function ( $expire, $issued_at ) {
time() + (DAY_IN_SECONDS * 7)
return $expire;
},
10,
2
);
It should look like this? And how to set expiry date to be two years?
And where do I need to add this code?
Thanks
-
This reply was modified 1 year, 11 months ago by
paxton111.
Plugin Author
Bagus
(@contactjavas)
Hi @paxton111 , the code above needs adjustment:
/**
* Change the token's expire value.
*
* @param int $expire The default "exp" value in timestamp.
* @param int $issued_at The "iat" value in timestamp.
*
* @return int The "expire" value.
*/
add_filter(
'jwt_auth_expire',
function ( $expire, $issued_at ) {
// Set $expire to 2 years.
$expire = time() + (DAY_IN_SECONDS * (2 * 365));
return $expire;
},
10,
2
);
Put this to functions.php in your theme. If it doesn’t work, create a plugin containing 1 file, activate it, and put your code there.
Let me know if that works for you 🙂
Best,
Bagus
Thanks, I will test this out!
Hey there,
So I noticed that the token is not valid anymore in Postman even tough I’ve set this expiration date to be two years.
What could be the issue?
Is there a way to test expiry date without waiting?
thanks