<p>You're options are:</p>

<ol>
<li><p>Adding it as a parameter in the querystring (e.g. domain.com?key1=value1)</p></li>
<li><p>Submitting it though a form and grabbing the value from POST.</p></li>
<li><p>Setting the value in a cookie and retrieving it on the next page using something like <a href="http://straightupcraft.com/craft-plugins/lj-cookies">this plugin</a>.</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, but especially options 3 and 4, so it's best to stick with simple strings.</p>

CC BY-SA 3.0
2014-07-10T17:23:45.047Z
2014-07-10T17:23:45.047Z
Brad Bell
<p>You sometime want to pass specific info from one page to another.</p>

<p>How do you do that with twig and are there explicit Craft methods to do this?
Can you do this without exposing the variable in the URL?</p>

<templating><variable><url>
Best practice on how to hand over variables with links?
# Best practice on how to hand over variables with links?

(Asked by: username_0 on 2014-07-10)

You sometime want to pass specific info from one page to another.

How do you do that with twig and are there explicit Craft methods to do this?
Can you do this without exposing the variable in the URL?

**Tags:** templating, variable, url

---

## 1 answers

### Answer by username_1 on 2014-07-10. Score: 6 | Accepted answer

You're options are:

1. Adding it as a parameter in the querystring (e.g. domain.com?key1=value1)
2. Submitting it though a form and grabbing the value from POST.
3. Setting the value in a cookie and retrieving it on the next page using something like [this plugin](http://straightupcraft.com/craft-plugins/lj-cookies).
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, but especially options 3 and 4, so it's best to stick with simple strings.


---

