Session

Sessions provide a stateless way to store information about the user across requests. The session tag will let you get, set, and forget session data.


Retrieving Session Data

You can use {{ session }} as a tag pair to access all the data inside your user’s session.

{{ session }}
    {{ message }}
{{ /session }}
Welcome to the session.

You can also retrieve single variables with a single tag syntax.

{{ session:message }}

Aliasing

If you need extra markup around your session data, you can alias a new child array variable.

{{ session as="sesh" }}
  {{ sesh }}
    {{ message }}
  {{ /sesh }}
{{ /session }}

Setting and Forgetting

You can set data with session:set, flash data with session:flash, forget it with session:forget, and flush the entire session with session:flush.

Debugging

If you want to peek into the session and check the data, do so with with session:dump or the debug bar.

Last modified on November 6, 2018