[Security][Session] Fix security sessions

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | ~
| License       | MIT
| Doc PR        | ~

I think that the previous patch, #7013 would introduce back the problem of starting the session earlier that needed for this case so I've deferred the execution of session related code to when it's actually needed.