Answers.Body: <p>Other than the query string, you're options are:</p>
  
  <ol>
  <li><p>Save it to a cookie and retrieve it from the next page with something like this <a href="http://straightupcraft.com/craft-plugins/lj-cookies" rel="nofollow">plugin</a>.</p></li>
  <li><p>Save it to <a href="http://buildwithcraft.com/classreference/etc/cache/FileCache" rel="nofollow">cache</a> (craft()->cache).</p></li>
  <li><p>Save it to PHP's $_SESSION, which Craft wraps with <a href="http://buildwithcraft.com/classreference/services/HttpSessionService" rel="nofollow">HttpSessionService</a> (craft()->httpSession).</p></li>
  <li><p>Writing a plugin with a Twig function that wraps Craft's <code>craft()-&gt;userSession-&gt;setFlash()</code> method, which will store a key->value pair in session for exactly one request. You can retrieve the value via <code>craft.userSession.getFlash()</code>.</p></li>
  </ol>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-05T04:03:11.383Z
Answers.Text: 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.
Answers.UserDisplayName: Ben Parizek
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-28T16:47:04.257Z
Answers.LastActivityDate: 2014-08-28T16:47:04.257Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have a form.  It submits.  It saves.  </p>
  
  <p>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.</p>
  
  <p>I do not want to pass the ID or any identifiable information in the URL.  Ideally, I'd like behavior just like using <code>setRouteVariables</code> </p>
  
  <pre><code>craft()-&gt;urlManager-&gt;setRouteVariables(array(
      'form' =&gt; $form
  ));
  </code></pre>
  
  <p>However, <code>setRouteVariables</code> does not work when using <code>$this-&gt;redirect()</code> or <code>$this-&gt;redirectToPostedUrl()</code>.</p>
  
  <p>I can successfully pass query string parameters back using the <code>redirect</code> method in the following way:</p>
  
  <pre><code>$this-&gt;redirect(array($redirectUrl,'dog'=&gt;'cat'), true); 
  </code></pre>
  
  <p>Is there any way to do this with posted variables that are not visible to the user?</p>
  
Tags: <plugin-development><routes>
Title: Is it possible to setRouteVariables when redirecting after a successful form submission?
ThreadText: # Is it possible to setRouteVariables when redirecting after a successful form submission?
  
  (Asked by: username_0 on 2014-08-28)
  
  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`
  
  ```
  craft()->urlManager->setRouteVariables(array(
      '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?
  
  **Tags:** plugin-development, routes
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-08-28. Score: 4 | Accepted answer
  
  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](http://straightupcraft.com/craft-plugins/lj-cookies).
  2. Save it to [cache](http://buildwithcraft.com/classreference/etc/cache/FileCache) (craft()->cache).
  3. Save it to PHP's $\_SESSION, which Craft wraps with [HttpSessionService](http://buildwithcraft.com/classreference/services/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.
  
  > **Comments:**
  > **username_0**: Very helpful. Thanks username_1.  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.  
  
  ---
  
  