SilverStripe: There seems to have been a technical problem

From FVue
Jump to: navigation, search


Within a SilverStripe project, after a successful submit, clicking the back button and submitting the form again, results in this error message (CSRF_FAILED_MESSAGE):

There seems to have been a technical problem. 
Please click the back button, refresh your browser, and try again.


  • SilverStripe-3.0.5


After a successful submit, the form does a Session::clear_all(), which clears the $_SESSION['SecurityID'] variable.

Solution 1. Clear session partially

Instead of a clear_all(), do this:


Solution 2. Force form-reload after redirect-back

The webbrowser can be forced to load a fresh form, with a new SecurityID, upon going back. This requires sending the Cache-Control: no-store http-header. This can be done by extending the Page_Controller like this:

public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
    $body = parent::handleRequest($request, $model);
    $body->addHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate, no-transform");
    return $body;