The Error
My Scenario
Firstly I know that this error message is a CSRF / session error message and that's fine; in fact it's behaving as expected. For reasons specific to my application I've made it so that to access an account I send a post request and build out the page depending on that response data.
The problem is that when the session times out on that page, my application does nothing, but throw this error message. I then physically have to type in a URL to get redirected to the login page which is not ideal for clients.
My Question
How do I control the behaviour of my application so I can modify what happens when this CSRF error occurs, for example if I wanted to make a custom page or use a controller to perform a redirect, etc.?
The difference is that I know what this error is. I want a way to redirect while this error is present, I'm not trying to stop the error from showing, and I'm trying to redirect from it. In my case it's not an error; it's a behaviour that I expect!