accessTokenExpired is null in session on PHP SDK

Hi there,

The response I get from getCredentials does not seem to contain any function for accessTokenExpired. When I print_r the $session, I see an access token expiry UNIX time, and an index “accessTokenExpired”, with nothing set to it, and calling that method I get an error confirming:

 Call to undefined method stdClass::accessTokenExpired()

My code is very simple, it’s just:

$session = $auth0->getCredentials();
$sessionExpiry = $session->accessTokenExpired();

I’m super confused because this seems like a well documented method that should exist? It’s baffling to me. I’m also confused about how I’m supposed to know when a new session has been started, and the existing one has been killed - how can I kill the existing session if, for example, someone else logged in with the same credentials on another computer?

Hi @admin71 :wave:

Sorry for the confusion! getCredentials() returns an object representing the state of the session but not a class that would contain functions. In this case, you would use:

$sessionExpirey = $session->accessTokenExpired, which will be a boolean.

1 Like

Thanks for the quick response, and from you! The reason I thought this was correct syntax was because of this in

Edit: That uses the correct syntax, not sure where I got it from in that case. Edit 2: OH you edited it :slight_smile: good to know im not crazy!

1 Like

Yeah thanks for spotting that! Entirely my bad

1 Like

Am I correct in saying this will return nothing unless it’s expired, in which case it returns true?

Right, it will return true when the authenticated session has expired, but false in all other cases. (Unless there isn’t an authenticated session at all, in which case getCredentials() returns null anyway.)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.