# Error when i use $auth0-\>exchange in php

**URL:** <https://community.auth0.com/t/error-when-i-use-auth0-exchange-in-php/99978>\
**Category:** Get Help\
**Tags:** authentication-sessions, sessions\
**Created:** [February 8, 2023, 10:52am UTC](https://community.auth0.com/t/error-when-i-use-auth0-exchange-in-php/99978 "2023-02-08T10:52:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![enyty](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/enyty/32/44441_2.png) [@enyty](https://community.auth0.com/u/enyty)\
**Post date:** [February 8, 2023, 10:52am UTC](https://community.auth0.com/t/error-when-i-use-auth0-exchange-in-php/99978/1 "2023-02-08T10:52:57Z")

</div>

Hello, I have a problem with the “$auth0-\>exchange(ROUTE\_URL\_CALLBACK)” function.

When I use it after login , it returns the following error: Uncaught Auth0\SDK\Exception\StateException: Missing code.

I’ve checked my URL and the code and the state are both there and it look likes good.

I need help please

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 8, 2023, 11:25am UTC](https://community.auth0.com/t/error-when-i-use-auth0-exchange-in-php/99978/2 "2023-02-08T11:25:39Z")

</div>

Hey there!

Can I ask you to raise it as a GitHub issue in our PHP SDK repo so we can discuss it directly with SDK maintainers? Once you have a link to it please share it here so we can ping them. Thank you!

---

<div class="post-metadata">

**Author:** ![enyty](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/enyty/32/44441_2.png) [@enyty](https://community.auth0.com/u/enyty)\
**Post date:** [February 8, 2023, 3:53pm UTC](https://community.auth0.com/t/error-when-i-use-auth0-exchange-in-php/99978/3 "2023-02-08T15:53:36Z")

</div>

> [@konrad.sopala](#):
>
> repo

here the links :

> <https://github.com/auth0/auth0-PHP/issues/704>
>
> \### Checklist
> 
> \- \[X\] The issue can be reproduced in a a sample app (either \[weba…pp\](https://github.com/auth0-samples/auth0-php-web-app) or \[api\](https://github.com/auth0-samples/auth0-php-api-samples)) (or N/A).
> \- \[X\] I have looked into the \[README\](https://github.com/auth0/auth0-PHP#readme) and have not found a suitable solution or answer.
> \- \[X\] I have looked into the \[examples\](https://github.com/auth0/auth0-PHP/blob/main/EXAMPLES.md) and have not found a suitable solution or answer.
> \- \[X\] I have looked into the \[API documentation\](https://auth0.github.io/auth0-PHP/) and have not found a suitable solution or answer.
> \- \[X\] I have searched the \[issues\](https://github.com/auth0/auth0-PHP/issues) and have not found a suitable solution or answer.
> \- \[X\] I have searched the \[Auth0 Community\](https://community.auth0.com/tag/auth0-php) forums and have not found a suitable solution or answer.
> \- \[X\] I agree to the terms within the \[Auth0 Code of Conduct\](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md).
> 
> \### SDK Version
> 
> Other (specify below)
> 
> \### PHP Version
> 
> Other (specify below)
> 
> \### Description
> 
> Hello, I have a problem with the “$auth0-\>exchange(ROUTE\_URL\_CALLBACK)” function.
> 
> When I use it after login , it returns the following error: Uncaught Auth0\\SDK\\Exception\\StateException: Missing code.
> 
> I’ve checked my URL and the code and the state are both there and it look likes good.
> 
> And also when i start it with this : php -S 127.0.0.1:3000 index.php
> Thats work and when i put it in my web server thats dont work and the error is back.
> 
> I use the version 8.3.1 of the SDK and the version 7.4.29 of php.
> 
> \### How can we reproduce this issue?
> 
> you just have to follow the quick start in a new php server

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 8, 2023, 3:59pm UTC](https://community.auth0.com/t/error-when-i-use-auth0-exchange-in-php/99978/4 "2023-02-08T15:59:31Z")

</div>

Thank you! I’ll ping them in a few minutes!

---

<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:** [February 22, 2023, 3:59pm UTC](https://community.auth0.com/t/error-when-i-use-auth0-exchange-in-php/99978/5 "2023-02-22T15:59:41Z")

</div>

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