# Checkout Invalid Token Exception

**URL:** <https://forum.shopware.com/t/checkout-invalid-token-exception/40553>\
**Category:** Allgemein\
**Created:** [14. Oktober 2016 um 15:12 UTC](https://forum.shopware.com/t/checkout-invalid-token-exception/40553 "2016-10-14T15:12:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![coarsy](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@coarsy](https://forum.shopware.com/u/coarsy)\
**Post date:** [14. Oktober 2016 um 15:12 UTC](https://forum.shopware.com/t/checkout-invalid-token-exception/40553/1 "2016-10-14T15:12:18Z")

</div>

Hi zusammen,

wenn man den Browser länger geöffnet hat, dann meinetwegen außer Haus geht und danach wieder  
den bereits geöffneten Browser verwendet und dann Artikel in den Warenkorb legt, erscheinen die  
vorher verwendeten Artikel wieder im Warenkorb.

Wenn man dann mit diesen Artikeln den Einkauf fortsetzt, seine Daten eingibt und dann zur Zahlungsartenauswahl  
gehen möchte, kommt diese Exception:

```
ERROR
Message: 	

exception 'Shopware\Components\CSRFTokenValidationException' with message 'The provided X-CSRF-Token is invalid. Please go back, reload the page and try again.' in /html/shopware/engine/Shopware/Components/CSRFTokenValidator.php:161
Stack trace:
#0 [internal function]: Shopware\Components\CSRFTokenValidator->checkFrontendTokenValidation(Object(Enlight_Controller_ActionEventArgs))
#1 /html/shopware/engine/Library/Enlight/Event/Handler/Default.php(91): call_user_func(Array, Object(Enlight_Controller_ActionEventArgs))
#2 /html/shopware/engine/Library/Enlight/Event/EventManager.php(214): Enlight_Event_Handler_Default->execute(Object(Enlight_Controller_ActionEventArgs))
#3 /html/shopware/engine/Library/Enlight/Controller/Action.php(143): Enlight_Event_EventManager->notify('Enlight_Control...', Object(Enlight_Controller_ActionEventArgs))
#4 /html/shopware/engine/Library/Enlight/Controller/Dispatcher/Default.php(523): Enlight_Controller_Action->dispatch('saveRegisterAct...')
#5 /html/shopware/engine/Library/Enlight/Controller/Front.php(223): Enlight_Controller_Dispatcher_Default->dispatch(Object(Enlight_Controller_Request_RequestHttp), Object(Enlight_Controller_Response_ResponseHttp))
#6 /html/shopware/engine/Shopware/Kernel.php(177): Enlight_Controller_Front->dispatch()
#7 /html/shopware/vendor/symfony/http-kernel/HttpCache/HttpCache.php(487): Shopware\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#8 /html/shopware/engine/Shopware/Components/HttpCache/AppCache.php(255): Symfony\Component\HttpKernel\HttpCache\HttpCache->forward(Object(Symfony\Component\HttpFoundation\Request), true, NULL)
#9 /html/shopware/vendor/symfony/http-kernel/HttpCache/HttpCache.php(258): Shopware\Components\HttpCache\AppCache->forward(Object(Symfony\Component\HttpFoundation\Request), true)
#10 /html/shopware/vendor/symfony/http-kernel/HttpCache/HttpCache.php(275): Symfony\Component\HttpKernel\HttpCache\HttpCache->pass(Object(Symfony\Component\HttpFoundation\Request), true)
#11 /html/shopware/engine/Shopware/Components/HttpCache/AppCache.php(133): Symfony\Component\HttpKernel\HttpCache\HttpCache->invalidate(Object(Symfony\Component\HttpFoundation\Request), true)
#12 /html/shopware/vendor/symfony/http-kernel/HttpCache/HttpCache.php(206): Shopware\Components\HttpCache\AppCache->invalidate(Object(Symfony\Component\HttpFoundation\Request), true)
#13 /html/shopware/engine/Shopware/Components/HttpCache/AppCache.php(114): Symfony\Component\HttpKernel\HttpCache\HttpCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /html/shopware/shopware.php(113): Shopware\Components\HttpCache\AppCache->handle(Object(Symfony\Component\HttpFoundation\Request))
#15 {main}

Time: 	

2016-10-14T17:07:12.451351+0200

Channel: 	

core

request: 	

{
    "uri": "/register/saveRegister/sTarget/checkout/sTargetAction/confirm",
    "method": "POST",
    "query": {
        "module": "frontend",
        "controller": "register",
        "action": "saveRegister",
        "sTarget": "checkout",
        "sTargetAction": "confirm"
    },
    "post": {
        "register": {
            "personal": {
                "customer_type": "private",
                "salutation": "mr",
                "firstname": "Christian",
                "lastname": "Bernhard",
                "accountmode": "1",
                "email": "chris@dreamride.de",
                "emailConfirmation": "bernhard@opus5.de",
                "phone": "",
                "birthday": {
                    "day": "",
                    "month": "",
                    "year": ""
                }
            },
            "billing": {
                "street": "Schubertweg 2",
                "zipcode": "64646",
                "city": "Heppenheim",
                "country": "2"
            },
            "shipping": {
                "company": "",
                "department": "",
                "firstname": "",
                "lastname": "",
                "street": "",
                "additionalAddressLine1": "",
                "zipcode": "",
                "city": ""
            }
        },
        "packstation": "Postadresse",
        "Submit": "",
        "__csrf_token": "A0qQbzWkkt86hmpJPg9qYmP3sunG6t"
    }
}

session: 	

No session data available

shopId: 	

1

shopName: 	

Hauptshop Deutsch

```

Was kann man hier unternehmen?

LG und Dankeschön,

Chris

---

<div class="post-metadata">

**Author:** ![NextMike](https://avatars.discourse-cdn.com/v4/letter/n/838e76/32.png) [@NextMike](https://forum.shopware.com/u/NextMike)\
**Post date:** [14. Oktober 2016 um 15:18 UTC](https://forum.shopware.com/t/checkout-invalid-token-exception/40553/2 "2016-10-14T15:18:36Z")

</div>

Evtl. ist die ganze CSRF Geschichte nicht ausgereift. Hier steht wie sie abgeschaltet werden kann:

[https://developers.shopware.com/developers-guide/csrf-protection/](https://developers.shopware.com/developers-guide/csrf-protection/)

---

<div class="post-metadata">

**Author:** ![coarsy](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@coarsy](https://forum.shopware.com/u/coarsy)\
**Post date:** [14. Oktober 2016 um 15:27 UTC](https://forum.shopware.com/t/checkout-invalid-token-exception/40553/3 "2016-10-14T15:27:42Z")

</div>

Also dann so, gell:

```
 array(
        'username' => '',
        'password' => '',
        'dbname' => 'usr__1',
        'host' => '',
        'port' => '3306'
    ),
    'front' => array(
    'throwExceptions' => false,
  ),
  'csrfProtection' => [
    'frontend' => false,
    'backend' => true
  ]
);

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![NextMike](https://avatars.discourse-cdn.com/v4/letter/n/838e76/32.png) [@NextMike](https://forum.shopware.com/u/NextMike)\
**Post date:** [14. Oktober 2016 um 15:29 UTC](https://forum.shopware.com/t/checkout-invalid-token-exception/40553/4 "2016-10-14T15:29:48Z")

</div>

sieht gut aus. Falls das Frontend oder Backend weiterhin laufen ist alls OK

---

<div class="post-metadata">

**Author:** ![coarsy](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@coarsy](https://forum.shopware.com/u/coarsy)\
**Post date:** [14. Oktober 2016 um 15:31 UTC](https://forum.shopware.com/t/checkout-invalid-token-exception/40553/5 "2016-10-14T15:31:18Z")

</div>

Yepp, läuft noch, aber wirklich strange… Eventuell lags auch daran, dass ich während dem Checkout den Cache geleert habe…

Danke jedenfalls, das Ding fliegt einem ständig um die Ohren!

Schönes Wochenende wünsche ich Dir!

---

<div class="post-metadata">

**Author:** ![Moritz\_Naczenski](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/moritz_naczenski/32/7792_2.png) [@Moritz\_Naczenski](https://forum.shopware.com/u/Moritz_Naczenski)\
**Post date:** [14. Oktober 2016 um 15:56 UTC](https://forum.shopware.com/t/checkout-invalid-token-exception/40553/6 "2016-10-14T15:56:05Z")

</div>

Der CSRF-Cookie bekommt die Laufzeit der Session (auf vielen Servern 24 Minuten). Wenn du diese Zeit wartest und dann ohne eine Seite aufzurufen direkt einen POST-Request ausführst, dann ist die Meldung völlig korrekt, denn du hast den Cookie ja auch noch garnicht. Der Sinn des Cookies ist ja, dass man ohne diesen keine POST-Requests ausführen kann.

Sehe da so erstmal keinen Fehler. Du kannst ggf. deine Session lifetime erhöhen um dem zu entgehen.

---

<div class="post-metadata">

**Author:** ![coarsy](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@coarsy](https://forum.shopware.com/u/coarsy)\
**Post date:** [14. Oktober 2016 um 16:00 UTC](https://forum.shopware.com/t/checkout-invalid-token-exception/40553/7 "2016-10-14T16:00:03Z")

</div>

Gut, habe die Lifetime nun mal auf das 4-fache erhöht… Die Kunden springen halt bei so einer “Ups” Fehlermeldung ab und sind frustriert und kommen so schnell nicht wieder…

---

<div class="post-metadata">

**Author:** ![econcess](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@econcess](https://forum.shopware.com/u/econcess)\
**Post date:** [31. Januar 2018 um 09:07 UTC](https://forum.shopware.com/t/checkout-invalid-token-exception/40553/8 "2018-01-31T09:07:36Z")

</div>

Wie in anderem Thread schon beschrieben (hat uns mehrere Stunden gekostet, dies nachzuvollziehen): Kann auch an einem älteren Browser liegen, bei uns war es der native Android-Browser auf einem Galaxy Tab 3 10.1 (GT-P5200). Hier muss eine Fallback-Lösung in einer Javascript-Datei implementiert werden. Lösung im Detail unter [https://www.econcess.de/blog/14-onlineshop-erstellung/148-shopware-invalides-formular-token-in-nativem-android-browser](https://www.econcess.de/blog/14-onlineshop-erstellung/148-shopware-invalides-formular-token-in-nativem-android-browser).
