# Invalid state (composer/php)

**URL:** <https://community.auth0.com/t/invalid-state-composer-php/107187>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [May 17, 2023, 3:57pm UTC](https://community.auth0.com/t/invalid-state-composer-php/107187 "2023-05-17T15:57:55Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhavith.chandra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bhavith.chandra/32/42478_2.png) [@bhavith.chandra](https://community.auth0.com/u/bhavith.chandra)\
**Post date:** [May 17, 2023, 3:57pm UTC](https://community.auth0.com/t/invalid-state-composer-php/107187/1 "2023-05-17T15:57:55Z")

</div>

I have implement log-in logout with quickstart php. and now i am getting this error. PHP Fatal error: Uncaught Auth0\SDK\Exception\StateException: Invalid state in C:\webpages\phptest\vendor\auth0\auth0-

$auth0 = new \Auth0\SDK\Auth0([  
‘domain’ =\> ‘[domain.eu.auth0.com](http://domain.eu.auth0.com)’,  
‘clientId’ =\>‘cientid’,  
‘clientSecret’ =\> ‘clientsecret’,  
‘cookieSecret’ =\>‘cookie secret’,  
‘redirectUri’ =\>‘[http://localhost/phptest/login.php](http://localhost/phptest/login.php)’

]);

if ($auth0-\>getExchangeParameters()) {  
// If they’re present, we should perform the code exchange.  
$auth0-\>exchange();  
}  
$session = $auth0-\>getCredentials();  
if ($session === null) {  
// User is not logged in!  
// Redirect to the Universal Login Page for authentication.  
header("Location: " . $auth0-\>login());  
exit;  
echo $session;  
}  
function () use($auth0) {  
// Clear the user’s local session with our app, then redirect them to the Auth0 logout endpoint to clear their Auth0 session.  
header("Location: " . $auth0-\>logout(‘[http://localhost/phptest/login.php](http://localhost/phptest/login.php)’));  
echo ‘logged out’;  
exit;  
};  
echo json\_encode($auth0,JSON\_PRETTY\_PRINT);  
echo json\_encode($session,JSON\_PRETTY\_PRINT);

---

<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:** [May 18, 2023, 12:17pm UTC](https://community.auth0.com/t/invalid-state-composer-php/107187/2 "2023-05-18T12:17:06Z")

</div>

Hey there!

In order to let us help you more effectively, can I ask you to share with us the link to the quickstart you were using? Thank you!

---

<div class="post-metadata">

**Author:** ![bhavith.chandra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bhavith.chandra/32/42478_2.png) [@bhavith.chandra](https://community.auth0.com/u/bhavith.chandra)\
**Post date:** [May 18, 2023, 12:32pm UTC](https://community.auth0.com/t/invalid-state-composer-php/107187/3 "2023-05-18T12:32:06Z")

</div>

HI @konrad.sopala [Auth0 PHP SDK Quickstarts: Login](https://auth0.com/docs/quickstart/webapp/php#integrate-your-php-application) this is the link i’ve been following.

---

<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:** [May 18, 2023, 12:35pm UTC](https://community.auth0.com/t/invalid-state-composer-php/107187/4 "2023-05-18T12:35:29Z")

</div>

Perfect! In order to handle that most effectively can I ask you to raise it as a GitHub issue here:

> **[Issues · auth0-samples/auth0-php-web-app](https://github.com/auth0-samples/auth0-php-web-app/issues)**
>
> Auth0 Integration Samples for PHP Web Applications - Issues · auth0-samples/auth0-php-web-app

so we can work on that directly with the quickstart maintainer and solve it in the shortest period of time? Once you have a link to it please share it here so we can ping them. Thank you!

---

<div class="post-metadata">

**Author:** ![bhavith.chandra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bhavith.chandra/32/42478_2.png) [@bhavith.chandra](https://community.auth0.com/u/bhavith.chandra)\
**Post date:** [May 18, 2023, 12:42pm UTC](https://community.auth0.com/t/invalid-state-composer-php/107187/5 "2023-05-18T12:42:33Z")

</div>

Thank you for the quick reply @konrad.sopala . I hvae raised the issue here [INVALID STATE(COMPOSER/PHP) · Issue #80 · auth0-samples/auth0-php-web-app · GitHub](https://github.com/auth0-samples/auth0-php-web-app/issues/80).

---

<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:** [May 18, 2023, 12:43pm UTC](https://community.auth0.com/t/invalid-state-composer-php/107187/6 "2023-05-18T12:43:04Z")

</div>

Perfect! Thank you! I’ll ping the repo maintainers in a few minutes!

---

<div class="post-metadata">

**Author:** ![bhavith.chandra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bhavith.chandra/32/42478_2.png) [@bhavith.chandra](https://community.auth0.com/u/bhavith.chandra)\
**Post date:** [May 18, 2023, 12:43pm UTC](https://community.auth0.com/t/invalid-state-composer-php/107187/7 "2023-05-18T12:43:43Z")

</div>

Cheers. Thank you 🙂

---

<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:** [May 18, 2023, 12:44pm UTC](https://community.auth0.com/t/invalid-state-composer-php/107187/8 "2023-05-18T12:44:02Z")

</div>

No problem! We’re here for you!

---

<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:** [May 22, 2023, 5:26pm UTC](https://community.auth0.com/t/invalid-state-composer-php/107187/9 "2023-05-22T17:26:01Z")

</div>

Hi, @bhavith.chandra 👋 Thanks for your question.

An invalid state occurs when the SDK encounters an issue reading anticipated cookies. When `login()` is called, a series of temporary cookies are stored on the client device. After authenticating with Auth0 and being returned to the application, during the `exchange()` call, the SDK checks that those cookies are present and match up with what was expected. An invalid state is thrown when they do not.

There could be any number of things interfering there:

- Browser settings or policies blocking cookies.
- Mixing 127.0.0.1 and localhost (each is considered a uniquely different host, and therefore has separate browser cookie jars.)
- Proxying web server software interfering with cookies (this is often the case with Apache and Nginx; make sure you up their cookie header limits if you’re using those.)

---

<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:** [June 5, 2023, 5:26pm UTC](https://community.auth0.com/t/invalid-state-composer-php/107187/10 "2023-06-05T17:26:03Z")

</div>

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