# accessTokenExpired is null in session on PHP SDK

**URL:** <https://community.auth0.com/t/accesstokenexpired-is-null-in-session-on-php-sdk/119767>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, auth0-php\
**Created:** [October 30, 2023, 8:08pm UTC](https://community.auth0.com/t/accesstokenexpired-is-null-in-session-on-php-sdk/119767 "2023-10-30T20:08:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![admin71](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/admin71/32/52072_2.png) [@admin71](https://community.auth0.com/u/admin71)\
**Post date:** [October 30, 2023, 8:08pm UTC](https://community.auth0.com/t/accesstokenexpired-is-null-in-session-on-php-sdk/119767/1 "2023-10-30T20:08:37Z")

</div>

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:

```auto
 Call to undefined method stdClass::accessTokenExpired()

```

My code is very simple, it’s just:

```auto
$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?

---

<div class="post-metadata">

**Author:** ![evansims](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evansims/32/27011_2.png) [@evansims](https://community.auth0.com/u/evansims)\
**Post date:** [October 30, 2023, 9:57pm UTC](https://community.auth0.com/t/accesstokenexpired-is-null-in-session-on-php-sdk/119767/2 "2023-10-30T21:57:20Z")

</div>

Hi @admin71 👋

Sorry for the confusion! `getCredentials()` returns [an object](https://github.com/auth0/auth0-PHP/blob/e36d3e13e208bb11e9f29a51c8685bed2f9c0b1c/src/Auth0.php#L335) 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.

---

<div class="post-metadata">

**Author:** ![admin71](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/admin71/32/52072_2.png) [@admin71](https://community.auth0.com/u/admin71)\
**Post date:** [October 30, 2023, 10:18pm UTC](https://community.auth0.com/t/accesstokenexpired-is-null-in-session-on-php-sdk/119767/3 "2023-10-30T22:18:22Z")

</div>

Thanks for the quick response, and from you! The reason I thought this was correct syntax was because of this in examples.md: [https://github.com/auth0/auth0-PHP/blob/6764f477abaad9cd2a415308a4f8c1b200358af7/EXAMPLES.md?plain=1#L168](https://github.com/auth0/auth0-PHP/blob/6764f477abaad9cd2a415308a4f8c1b200358af7/EXAMPLES.md?plain=1#L168)

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

---

<div class="post-metadata">

**Author:** ![evansims](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evansims/32/27011_2.png) [@evansims](https://community.auth0.com/u/evansims)\
**Post date:** [October 30, 2023, 10:21pm UTC](https://community.auth0.com/t/accesstokenexpired-is-null-in-session-on-php-sdk/119767/4 "2023-10-30T22:21:32Z")

</div>

Yeah thanks for spotting that! Entirely my bad

---

<div class="post-metadata">

**Author:** ![admin71](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/admin71/32/52072_2.png) [@admin71](https://community.auth0.com/u/admin71)\
**Post date:** [October 30, 2023, 11:06pm UTC](https://community.auth0.com/t/accesstokenexpired-is-null-in-session-on-php-sdk/119767/5 "2023-10-30T23:06:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![evansims](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evansims/32/27011_2.png) [@evansims](https://community.auth0.com/u/evansims)\
**Post date:** [October 30, 2023, 11:56pm UTC](https://community.auth0.com/t/accesstokenexpired-is-null-in-session-on-php-sdk/119767/6 "2023-10-30T23:56:21Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 13, 2023, 11:56pm UTC](https://community.auth0.com/t/accesstokenexpired-is-null-in-session-on-php-sdk/119767/7 "2023-11-13T23:56:34Z")

</div>

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