I have a form. It submits. It saves.

I'd like to pass the newly-created, complete form object back to the 'thank you' page template so that I can display the values that were submitted.

I do not want to pass the ID or any identifiable information in the URL. Ideally, I'd like behavior just like using setRouteVariables

    'form' => $form

However, setRouteVariables does not work when using $this->redirect() or $this->redirectToPostedUrl().

I can successfully pass query string parameters back using the redirect method in the following way:

$this->redirect(array($redirectUrl,'dog'=>'cat'), true); 

Is there any way to do this with posted variables that are not visible to the user?

1 Answer 1


Other than the query string, you're options are:

  1. Save it to a cookie and retrieve it from the next page with something like this plugin.

  2. Save it to cache (craft()->cache).

  3. Save it to PHP's $_SESSION, which Craft wraps with HttpSessionService (craft()->httpSession).

  4. Writing a plugin with a Twig function that wraps Craft's craft()->userSession->setFlash() method, which will store a key->value pair in session for exactly one request. You can retrieve the value via craft.userSession.getFlash().

Note that there are limitations to the size and complexity of the data you can pass along with all of these and in almost all cases, the data needs to be serializable.

  • Very helpful. Thanks Brad. I ended up storing an ID in the $_SESSION and retrieving that ID and destroying the session variable on the thank you page. I might have missed something but craft()->userSession->setFlash() didn't seem to work. setNotice() worked, but I couldn't seem to use userSession to set a flash variable with a custom key name. Oct 5, 2014 at 4:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.