# \[Solved\]: Trouble upgrading to slim/csrf 0.8

**URL:** <https://discourse.slimframework.com/t/solved-trouble-upgrading-to-slim-csrf-0-8/2413>\
**Category:** Questions\
**Created:** [May 14, 2018, 10:48pm UTC](https://discourse.slimframework.com/t/solved-trouble-upgrading-to-slim-csrf-0-8/2413 "2018-05-14T22:48:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheLobos](https://avatars.discourse-cdn.com/v4/letter/t/e9bcb4/32.png) [@TheLobos](https://discourse.slimframework.com/u/TheLobos)\
**Post date:** [May 14, 2018, 10:48pm UTC](https://discourse.slimframework.com/t/solved-trouble-upgrading-to-slim-csrf-0-8/2413/1 "2018-05-14T22:48:56Z")

</div>

I’ve been using slim/csrf 0.5 for ages now and never had a problem. While reviewing my composer.json I noticed that now 0.8.2 is available so I changed the version referenced in my composer.json to “^0.8”.

After upgrading, now none of my forms manage to pass the CSRF validation stage. Here is the code I’m using:

1. dependencies.php

2. In my Twig extension I’m using the following functions which I then call in my template:

3. In my form processing code I’m calling:

Now, the odd thing is that the csrf\_status property is never populated in the request, so the call from #3 always return null (the default).

Also, while my templates are generating seemingly valid csrf tokens, the token names/values never make it to the CSRF storage.

I’ve been staring at this for a while now and I’m drawing a blank. Does anybody see what I’m doing wrong here? I’m guessing that I’m overlooking something totally stupid, but so far it escapes me.

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![TheLobos](https://avatars.discourse-cdn.com/v4/letter/t/e9bcb4/32.png) [@TheLobos](https://discourse.slimframework.com/u/TheLobos)\
**Post date:** [May 15, 2018, 9:51am UTC](https://discourse.slimframework.com/t/solved-trouble-upgrading-to-slim-csrf-0-8/2413/2 "2018-05-15T09:51:14Z")

</div>

Figured it out, apparently my brain was too tired to follow instructions. I failed to do a

```
$slimGuard->validateStorage();

```

For reference, my initialization code in dependencies.php now looks like this:

```
 $container['csrf'] = function($container) {
    $guard = new \Slim\Csrf\Guard();
    $guard->validateStorage();
    $guard->setFailureCallable(function($request, $response, $next) {
        $request = $request->withAttribute("csrf_status", false);
        return $next ($request, $response);
    });

    return $guard;
};
```
