# When you log out of Okta it does not redirect to the application page

**URL:** <https://devforum.okta.com/t/when-you-log-out-of-okta-it-does-not-redirect-to-the-application-page/21830>\
**Category:** OAuth/OIDC\
**Created:** [September 9, 2022, 1:29pm UTC](https://devforum.okta.com/t/when-you-log-out-of-okta-it-does-not-redirect-to-the-application-page/21830 "2022-09-09T13:29:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![denis.futida](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@denis.futida](https://devforum.okta.com/u/denis.futida)\
**Post date:** [September 9, 2022, 1:29pm UTC](https://devforum.okta.com/t/when-you-log-out-of-okta-it-does-not-redirect-to-the-application-page/21830/1 "2022-09-09T13:29:56Z")

</div>

The logout URL is:  
https://{subdomain}}.okta.com/oauth2/default/v1/logout?id\_token\_hint=“.$\_SESSION[‘okta\_id\_token’].”&post\_logout\_redirect\_uri=[http://google.com](http://google.com)

In the Okta Admin Panel:  
Sign-out redirect URIs: [http://google.com](http://google.com)

But it still doesn’t redirect. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![denis.futida](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@denis.futida](https://devforum.okta.com/u/denis.futida)\
**Post date:** [September 9, 2022, 2:27pm UTC](https://devforum.okta.com/t/when-you-log-out-of-okta-it-does-not-redirect-to-the-application-page/21830/2 "2022-09-09T14:27:48Z")

</div>

It seems that you need to close the session to do the redirect, but I would like to do this using Curl, but how to get the okta\_session\_cookie in PHP?

> **[Sessions | Okta Developer](https://developer.okta.com/docs/reference/api/sessions/#get-current-session)**
>
> Secure, scalable, and highly available authentication and user management for any app.

---

<div class="post-metadata">

**Author:** ![denis.futida](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@denis.futida](https://devforum.okta.com/u/denis.futida)\
**Post date:** [September 9, 2022, 7:36pm UTC](https://devforum.okta.com/t/when-you-log-out-of-okta-it-does-not-redirect-to-the-application-page/21830/3 "2022-09-09T19:36:23Z")

</div>

@andrea just need to redirect to logout URL for me to finish Okta authentication. Can you help me please?

---

<div class="post-metadata">

**Author:** ![denis.futida](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@denis.futida](https://devforum.okta.com/u/denis.futida)\
**Post date:** [September 9, 2022, 8:16pm UTC](https://devforum.okta.com/t/when-you-log-out-of-okta-it-does-not-redirect-to-the-application-page/21830/4 "2022-09-09T20:16:36Z")

</div>

Just for the record, I managed to redirect to the application when Okta logs out.

It was necessary to close the session and sign out in javascript

var config = {  
issuer: ‘\<?=$\_ENV['OKTA\_OAUTH2\_ISSUER']?\>’  
};

var authClient = new OktaAuth(config);

const revokeAccessTok = async function() {  
await authClient.revokeAccessToken(); // strongly recommended  
}  
authClient.closeSession();

// Sign out using the default options  
authClient.signOut()

// Override the post logout URI for this call  
authClient.signOut({  
postLogoutRedirectUri: ´${location.origin}/mdlStart/index.php/logout´  
});

// In this case, the ID token is stored under the ‘myIdToken’ key  
const id\_token = async function() {  
var idToken = await authClient.tokenManager.get(‘\<?=$\_SESSION['okta\_id\_token']?\>’);  
authClient.signOut({  
idToken: idToken  
});  
}

// In this case, the access token is stored under the ‘myAccessToken’ key  
const access\_token = async function() {  
var accessToken = await authClient.tokenManager.get(‘\<?=$\_SESSION['okta\_access\_token']?\>’);  
authClient.signOut({  
accessToken: accessToken  
});  
}

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [September 10, 2022, 8:17pm UTC](https://devforum.okta.com/t/when-you-log-out-of-okta-it-does-not-redirect-to-the-application-page/21830/5 "2022-09-10T20:17:22Z")

</div>

Closed on September 10, 2022, 8:17pm UTC

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