# The provided X-CSRF-Token is invalid

**URL:** <https://forum.shopware.com/t/the-provided-x-csrf-token-is-invalid/41281>\
**Category:** Programmierung\
**Created:** [11. November 2016 um 09:48 UTC](https://forum.shopware.com/t/the-provided-x-csrf-token-is-invalid/41281 "2016-11-11T09:48:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![megadruck](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@megadruck](https://forum.shopware.com/u/megadruck)\
**Post date:** [11. November 2016 um 09:48 UTC](https://forum.shopware.com/t/the-provided-x-csrf-token-is-invalid/41281/1 "2016-11-11T09:48:49Z")

</div>

Eine Frage habe ich zu " The provided X-CSRF-Token is invalid "

&nbsp;

```
    public function preDispatch()
    {

        if( in_array($this->Request()->getActionName(),
            array( "getConfig","doDelete","doInsert" )) )
        {
            Shopware()->Plugins()->Controller()->ViewRenderer()->setNoRender();
        }

        $this->admin = Shopware()->Modules()->Admin();
        Shopware()->Session()->mdID = ($this->Request()->get("id"))? (int)$this->Request()->get("id"):Shopware()->Session()->get("mdID");

        if (!$this->admin->sCheckUser()) {
          return $this->redirect(
              array(
                  'controller' => 'account',
                  'action' => 'index',
                  'sTarget' => 'transfer',
                  'sTargetAction' => 'index'
                  )
          );
        }
    }

```

Der Kunde ruft auf

/transfer/index/id/123456/

und springt zum Login, wenn dieser nicht eingeloggt ist. Danach geht es weiter zu

/transfer/index/

Die id habe ich vorher in eine Session gespeichert und rufe diese ab.

&nbsp;

Problem: Wenn die Session abläuft gibt es ein redirect zu, /account/ und **NACH** dem Login

kommt die meldung " The provided X-CSRF-Token is invalid. Please go back, reload the page and try again "

&nbsp;

Wie kann ich das vermeiden ?
