Make the session available as early as possible

The session object needs to be available as early as possible in case an error is thrown before the correct session can be setup since the session object is used for displaying the error page.

cc @DeepDiver1975 @PVince81