Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 6 down vote accepted

You're options are:

  1. Adding it as a parameter in the querystring (e.g.

  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.

  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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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