Radical Design Course by Jack McDade

From the creator of Statamic

Learn how to make your websites standout and be remembered.

This course is the most refreshing take on teaching design that I've come across.

— Mikaël Sévigny, Developer

Session:Set Tag

Data set in the session will be available in all future requests until such time that the session is cleared over time (sessions eventually expire) or intentionally. Session variables can be retrieved with the main session tag.

Example

This can be used for many different things. For example, you could set a variable on the form success page if a user has filled out a special survey form.

{{ session:set entered_survey="true" }}

Later you could decide to show a message instead of the form if the user has already filled it out.

{{ session }}
{{ if entered_survey }}
<p>You already filled out the form.</p>
{{ /if }}
{{ /session }}

Multiple Variables

You can set multiple variables at once and reference interpolated data (references to variables).

{{ session:set likes="hats" :visited="url" }}

Tag Pair

This tag is also available as a pair, which can be used to immediately display set data.

{{ session:set likes="boomboxes" }}
<p>You like {{ likes }}, huh?</p>
{{ /session:set }}

Setting Array Data

Array data can be set with dot notation.

{{ session:set likes.books="true" likes.hats="true" }}

Forgetting Data

Data can be removed from the session session:forget, and the entire session flushed with session:flush. 🚽

Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →