Tags

set_session

Store values in the web session for cross-page persistence

Last updated: · Published:

The set_session tag allows you to store values in the web session. This enables a website to 'remember' values across multiple pages and requests. This can be used, for example, to assemble a list of products and then submit these via one form.

Variables set using this tag can be retrieved using the session object.

Parameters

The tag accepts two (unnamed) arguments:

The variable name

  • A string containing only alphanumeric characters and underscores

The variable value

  • A string or number, at most 5000 characters long
  • Note: Numbers are converted to strings when stored

Example

The following code sets the session variable 'first_name' to have the value 'Plate':

{% set_session "first_name", "Plate" %}

After this, {{ session.first_name }} will output Plate.


Copyright © 2025